コード例 #1
0
ファイル: ImageMaker.cs プロジェクト: UmaxSoftWorks/UDS2
 /// <summary>
 /// Load settings from file
 /// </summary>
 /// <param name="ImagePath">File path</param>
 public virtual void Load(string ImagePath)
 {
     try
     {
         this.Settings = (IImageSettings)CustomXmlDeserializer.Deserialize(IO.File.ReadAllText(IO.Path.Combine(ImagePath, "images.xml"), Encoding.Default), 1);
     }
     catch (Exception) { }
 }
コード例 #2
0
        public virtual void Load(string TaskPath)
        {
            try
            {
                this.Settings =
                    (ITaskSettings)
                    CustomXmlDeserializer.Deserialize(
                        IO.File.ReadAllText(IO.Path.Combine(TaskPath, "task.xml"), Encoding.Default), 1);

                // Initializing text maker
                for (int i = 0; i < this.Text.Makers.Count; i++)
                {
                    if (this.Text.Makers[i].GUIName == (this.Settings as TaskSettings).TextMakerName)
                    {
                        this.TextMaker = (ITextMaker)this.Text.Makers[i].NewInstance();
                        this.TextMaker.Load(TaskPath);

                        if (this.TextMaker is ITextDataCompatible)
                        {
                            (this.TextMaker as ITextDataCompatible).TextData = this.Data.Select((this.Settings as TaskSettings).WorkSpaceID, ItemSelectType.ID).Text;
                        }

                        break;
                    }
                }

                // Initializing image maker
                if ((this.Settings as TaskSettings).Images)
                {
                    for (int i = 0; i < this.Images.Makers.Count; i++)
                    {
                        if (this.Images.Makers[i].GUIName == (this.Settings as TaskSettings).ImageMakerName)
                        {
                            this.ImageMaker = (IImageMaker)this.Images.Makers[i].NewInstance();
                            this.ImageMaker.Load(TaskPath);

                            if (this.ImageMaker is IImageDataCompatible)
                            {
                                (this.ImageMaker as IImageDataCompatible).ImageData = this.Data.Select((this.Settings as TaskSettings).WorkSpaceID, ItemSelectType.ID).Images;
                            }

                            break;
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }
コード例 #3
0
        /// <summary>
        /// Loads settings from data source and returns it.
        /// </summary>
        /// <returns></returns>
        protected static Settings Load()
        {
            Settings settings = null;

            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(Path.Combine(CraftSynth.BuildingBlocks.Common.Misc.ApplicationRootFolderPath, Settings.FilePath));
                settings = (Settings)CustomXmlDeserializer.Deserialize(doc.OuterXml, 1, new TestMeTypeConverter());
                //Helper.Deserialize(typeof(Settings), FilePath);
            }
            catch (Exception exception)
            {
                Common.Logging.AddExceptionLog(exception);
            }
            return(settings);
        }
コード例 #4
0
 public T getSharedObject()
 {
     try
     {
         lock (this._synLock)
         {
             byte[] array = this.ReadShareArray(0L, 8L + this._shareMemSize);
             long   num   = BitConverter.ToInt64(array, 0);
             if (num <= this._shareMemSize)
             {
                 byte[] array2 = new byte[num];
                 Array.Copy(array, 8L, array2, 0L, num);
                 string @string = Encoding.UTF8.GetString(array2);
                 return((T)((object)CustomXmlDeserializer.Deserialize(@string, 8, new TestMeTypeConverter())));
             }
         }
     }
     catch (Exception)
     {
     }
     return(default(T));
 }
コード例 #5
0
        /// <summary>
        /// Loads settings from data source and returns it.
        /// </summary>
        /// <returns></returns>
        protected static Settings Load()
        {
            Settings settings = null;

            try
            {
                lock (_fileSyncLock)
                {
                    string content = File.ReadAllText(Settings.FilePath);
                    content = Settings.UpgradeContentToLatestVersionWhereOldRecognized(content);
                    File.WriteAllText(Settings.FilePath, content);

                    XmlDocument doc = new XmlDocument();
                    doc.Load(Settings.FilePath);
                    settings = (Settings)CustomXmlDeserializer.Deserialize(doc.OuterXml, 1, new TestMeTypeConverter());
                    //Helper.Deserialize(typeof(Settings), FilePath);
                }
            }
            catch (Exception exception)
            {
                Common.Logging.AddExceptionLog(exception);
            }
            return(settings);
        }