当前位置: 首页>>代码示例>>C#>>正文


C# IMedia.GetValue方法代码示例

本文整理汇总了C#中IMedia.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# IMedia.GetValue方法的具体用法?C# IMedia.GetValue怎么用?C# IMedia.GetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMedia的用法示例。


在下文中一共展示了IMedia.GetValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UmbracoEventFile

 public UmbracoEventFile(IMedia im)
 {
     Id = im.Id;
     File = Kraken.GetImage(im); // Filename
     // Read height
     var propertyValue = im.GetValue(Constants.UmbracoPropertyAliasHeight);
     if (propertyValue != null)
         if (propertyValue is int)
             _height = (int)propertyValue;
         else
             int.TryParse(propertyValue as String, out _height);
     // Read width
     propertyValue = im.GetValue(Constants.UmbracoPropertyAliasWidth);
     if (propertyValue != null)
         if (propertyValue is int)
             _width = (int)propertyValue;
         else
             int.TryParse(propertyValue as String, out _width);
     // Read size
     propertyValue = im.GetValue(Constants.UmbracoPropertyAliasSize);
     if (propertyValue != null)
         if (propertyValue is int)
             _size = (int)propertyValue;
         else int.TryParse(propertyValue as String, out _size);
 }
开发者ID:PerplexInternetmarketing,项目名称:Perplex-Kraken,代码行数:25,代码来源:UmbracoEvents.cs

示例2: HasChanged

            public bool HasChanged(IMedia im)
            {
                if (im != null)
                {
                    // Keep in mind: new media nodes are always 0 in the "saving" event
                    var uef = _eventFiles.FirstOrDefault(x => x.Id == im.Id);
                    if (uef != null)
                    {
                        // Read height
                        int height = 0, width = 0, size = 0;
                        var propertyValue = im.GetValue(Constants.UmbracoPropertyAliasHeight);
                        if (propertyValue != null)
                            if (propertyValue is int)
                                height = (int)propertyValue;
                            else
                                int.TryParse(propertyValue as String, out height);
                        // Read width
                        propertyValue = im.GetValue(Constants.UmbracoPropertyAliasWidth);
                        if (propertyValue != null)
                            if (propertyValue is int)
                                width = (int)propertyValue;
                            else
                                int.TryParse(propertyValue as String, out width);
                        // Read size
                        propertyValue = im.GetValue(Constants.UmbracoPropertyAliasSize);
                        if (propertyValue != null)
                            if (propertyValue is int)
                                size = (int)propertyValue;
                            else int.TryParse(propertyValue as String, out size);

                        return uef.File != Kraken.GetImage(im) ||
                               uef.Height != height ||
                               uef.Width != width ||
                               uef.Size != size;
                    }
                }
                return false;
            }
开发者ID:PerplexInternetmarketing,项目名称:Perplex-Kraken,代码行数:38,代码来源:UmbracoEvents.cs

示例3: GetCropUpUrl

        /// <summary>
        /// Method for getting CropUp url by image
        /// </summary>
        /// <param name="image">IMedia</param>
        /// <param name="cropUpAlias">CropUp alias (optional)</param>
        /// <returns>string</returns>
        private static string GetCropUpUrl(IMedia image, string cropUpAlias = null)
        {
            if (string.IsNullOrEmpty(cropUpAlias))
                return CropUp.GetUrl(image.GetValue<string>("umbracoFile"));

            return CropUp.GetUrl(image.GetValue<string>("umbracoFile"),
                                 new ImageSizeArguments() { CropAlias = cropUpAlias });
        }
开发者ID:pjengaard,项目名称:lilleGrundetDk,代码行数:14,代码来源:MediaMapper.cs

示例4: ImportMediaFile

        public static void ImportMediaFile(Guid guid, IMedia item)
        {
            string fileroot = IOHelper.MapPath(_mappedFilesRoot);
            string folder = Path.Combine(fileroot, guid.ToString());

            LogHelper.Debug<FileHelper>("Importing {0}", () => folder);
            if (!Directory.Exists(folder))
                return;

            //
            // we look for an existing folder, if it's there we get the
            // file info. we only want to import changed files, as it 
            // creates directories all the time
            //

            FileInfo currentFile = null; 
            // some is it already there logic ? 
            if (item.HasProperty("umbracoFile"))
            {
                LogHelper.Debug<FileHelper>("Has umbracoFile");
                if (item.GetValue("umbracoFile") != null)
                {
                    LogHelper.Debug<FileHelper>("umbracoFile value [{0}]", () => item.GetValue("umbracoFile").ToString() );
                    string umbracoFile = item.GetValue("umbracoFile").ToString();

                    // standard uploaded the path is a string . 
                    // for Umbraco 7's image cropper it's all JSON
                    string path = umbracoFile;
                    if ( !string.IsNullOrWhiteSpace(umbracoFile))
                    {
                        if ( IsJson(umbracoFile))
                        {
                            var jsonUmbracoFile = JsonConvert.DeserializeObject<dynamic>(umbracoFile);
                            path = jsonUmbracoFile.src;
                        }
                    }

                    LogHelper.Debug<FileHelper>("path {0}", () => path);

                    if (!string.IsNullOrWhiteSpace(path))
                    {
                        //
                        // we check it's in the media folder, because later we delete it and all it's sub folders
                        // if for some reason it was blank or mallformed we could trash the whole umbraco just here.
                        //
                        if (path.StartsWith("/media/"))
                        {
                            string f = IOHelper.MapPath(string.Format("~{0}", path));
                            if (System.IO.File.Exists(f))
                            {
                                LogHelper.Debug<FileHelper>("Getting info for {0}", () => f);
                                currentFile = new FileInfo(f);
                            }
                        }
                    }
                }
            }




            foreach (var file in Directory.GetFiles(folder, "*.*"))
            {

                LogHelper.Debug<FileHelper>("Import {0}", () => file);


                if (currentFile != null)
                {
                    // LogHelper.Debug<FileHelper>("Comparing {0} - {1}", () => currentFile.Name, () => file);
                    // do some file comparison, we only import if the new file
                    // is diffrent than the existing one..
                    if (!FilesAreEqual(currentFile, new FileInfo(file)))
                    {
                        LogHelper.Info<FileHelper>("Updating umbracoFile with {0} ", () => file);
                        string filename = Path.GetFileName(file);

                        FileStream s = new FileStream(file, FileMode.Open);
                        item.SetValue("umbracoFile", filename, s); // question this for imagecropper types... 
                        s.Close();

                        // ok so now we've gone and created a new folder, we need to delete the old on
                        if (Directory.Exists(currentFile.DirectoryName))
                        {
                            LogHelper.Info<FileHelper>("Removing old media folder location {0}", () => currentFile.DirectoryName);
                            Directory.Delete(currentFile.DirectoryName, true);
                        }
                    }
                    // LogHelper.Debug<FileHelper>("Done comparing {0} - {1}", () => currentFile.Name, () => file);
                }
                else
                {
                    // if we have no currentfile, that's because it's not been imported first time yet.
                    LogHelper.Info<FileHelper>("First time import of {0}", () => file);

                    FileStream s = new FileStream(file, FileMode.Open);
                    item.SetValue("umbracoFile", Path.GetFileName(file), s);
                    s.Close();
                }
                LogHelper.Debug<FileHelper>("<< Done Import {0}", () => file);
//.........这里部分代码省略.........
开发者ID:pbevis,项目名称:jumoo.usync,代码行数:101,代码来源:FileHelper.cs


注:本文中的IMedia.GetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。