コード例 #1
0
        public void Deserialize(string content)
        {
            // make sure that the parameter starts with COMPLETED
            if (!content.ToUpper().StartsWith(Markup))
            {
                throw new ArgumentException($"Invalid completed detected! Component property needs to start with { Markup } keyword!");
            }

            // deserialize parameters
            Parameters =
                content.Substring(Markup.Length, content.IndexOf(':') - Markup.Length)
                .Split(';', StringSplitOptions.RemoveEmptyEntries)
                .Select(x => CalendarFactory.DeserializePropertyParameter(x))
                .ToList();

            // extract the value content
            string valueContent = content.Substring(content.IndexOf(':') + 1).Trim();

            DateTime = ObjectSerializer.Deserialize <DateTimeValue>(valueContent);
        }
コード例 #2
0
ファイル: PluginMain.cs プロジェクト: tielobraga/flashdevelop
 /// <summary>
 /// Loads the serialized binary file
 /// </summary>
 public String LoadBinaryFile(String file)
 {
     try
     {
         Object       settings = new Object();
         MemoryStream stream   = new MemoryStream();
         settings = ObjectSerializer.Deserialize(file, settings, false);
         XmlSerializer xs = new XmlSerializer(settings.GetType());
         xs.Serialize(stream, settings); // Obj -> XML
         XmlTextWriter xw = new XmlTextWriter(stream, Encoding.UTF8);
         xw.Formatting = Formatting.Indented; stream.Close();
         this.objectTypes.Add(new TypeData(file, settings.GetType()));
         return(Encoding.UTF8.GetString(stream.ToArray()));
     }
     catch (Exception ex)
     {
         ErrorManager.ShowError(ex);
         return(null);
     }
 }
コード例 #3
0
        public IList <AnalogHistoryHour> getByAnalogNoAndTimeGap(int AnalogNo, DateTime startTime, DateTime endTime)
        {
            IList <AnalogHistoryHour> ipdList = new List <AnalogHistoryHour>();

            try
            {
                IList <AnalogHistoryHour> ipdRedis = ser.Deserialize(redis.Get <byte[]>(AnalogNo.ToString())) as IList <AnalogHistoryHour>;
                for (int i = 0; i < ipdRedis.Count; i++)
                {
                    if (startTime <= ipdRedis[i].AHH_HTime && ipdRedis[i].AHH_HTime <= endTime)
                    {
                        ipdList.Add(ipdRedis[i]);
                    }
                }
            }catch (Exception ex)
            {
                log.write("Func:getByAnalogNoAndTimeGap:" + ex.Message);
            }
            return(ipdList);
        }
コード例 #4
0
        protected virtual Response.ICOMS ReceiveResponse(WebResponse rsp)
        {
            Response.ICOMS rspicoms = null;
            Stream         strm     = null;
            StreamReader   rdr      = null;

            try
            {
                strm = rsp.GetResponseStream();
                // NOTE: Cannot use XmlTextReader. It complains and gives
                // an empty string. instead use the generic StreamReader
                rdr      = new StreamReader(strm);
                rspicoms = (Response.ICOMS)ObjectSerializer.Deserialize(
                    rdr.ReadToEnd(), typeof(Response.ICOMS));

                // TODO: Trace response???
            }             // try
            catch (IOException excIo)
            {
                Debug.WriteLine(excIo);
                throw new CmUnavailableException(excIo);
            }             // catch( IOException excIo )
            catch (Exception exc)
            {
                Debug.WriteLine(exc);
                throw new CmProxyException(exc);
            }             // catch( Exception exc )
            finally
            {
                if (null != rdr)
                {
                    rdr.Close();
                }
                if (null != strm)
                {
                    strm.Close();
                }
            }             // finally

            return(rspicoms);
        }          // ReceiveResponse()
コード例 #5
0
        /// <summary>
        /// Loads the plugin settings
        /// </summary>
        public void LoadSettings()
        {
            string dataPath = Path.Combine(PathHelper.DataDir, "fdTFS");

            if (!Directory.Exists(dataPath))
            {
                Directory.CreateDirectory(dataPath);
            }
            settingsFilename = Path.Combine(dataPath, "Settings.fdb");

            Settings = new Settings();
            if (!File.Exists(settingsFilename))
            {
                this.SaveSettings();
            }
            else
            {
                object obj = ObjectSerializer.Deserialize(this.settingsFilename, Settings);
                Settings = (Settings)obj;
            }
        }
コード例 #6
0
 public void LoadSettings()
 {
     if (File.Exists(settingFilename))
     {
         try
         {
             settingObject = new Settings();
             settingObject = (Settings)ObjectSerializer.Deserialize(settingFilename, settingObject);
         }
         catch
         {
             settingObject = new Settings();
             SaveSettings();
         }
     }
     else
     {
         settingObject = new Settings();
         SaveSettings();
     }
 }
コード例 #7
0
ファイル: PluginMain.cs プロジェクト: littlesome/LuaDevelop
 public void LoadSettings()
 {
     Settings = new ProjectManagerSettings();
     if (!Directory.Exists(SettingsDir))
     {
         Directory.CreateDirectory(SettingsDir);
     }
     if (!File.Exists(SettingsPath))
     {
         this.SaveSettings();
     }
     else
     {
         Object obj = ObjectSerializer.Deserialize(SettingsPath, Settings);
         Settings = (ProjectManagerSettings)obj;
         PatchSettings();
     }
     // set manually to avoid dependency in FDBuild
     FileInspector.ExecutableFileTypes = Settings.ExecutableFileTypes;
     Settings.Changed += SettingChanged;
 }
コード例 #8
0
 /// <summary>
 /// Load the form state from a setting file and applies it
 /// </summary>
 private void SmartFormLoad(Object sender, EventArgs e)
 {
     if (!String.IsNullOrEmpty(this.formGuid) && File.Exists(this.FormPropsFile))
     {
         Object obj = ObjectSerializer.Deserialize(this.FormPropsFile, this.formProps);
         this.formProps = (FormProps)obj;
         if (!this.formProps.WindowSize.IsEmpty)
         {
             this.Size = this.formProps.WindowSize;
         }
     }
     if (!String.IsNullOrEmpty(this.helpLink))
     {
         this.HelpButton         = true;
         this.HelpButtonClicked += new System.ComponentModel.CancelEventHandler(this.SmartFormHelpButtonClick);
     }
     if (this.ApplyProps != null)
     {
         this.ApplyProps(this);
     }
 }
コード例 #9
0
        /// <summary>
        /// Restore intermediate test results.
        /// </summary>
        /// <param name="executionLogPath"></param>
        /// <returns></returns>
        internal static List <TestRecord> LoadIntermediateTestRecords(DirectoryInfo executionLogPath)
        {
            List <TestRecord> results         = null;
            FileInfo          resultsFileInfo = new FileInfo(Path.Combine(executionLogPath.FullName, serializationFileName));

            if (resultsFileInfo.Exists)
            {
                try
                {
                    using (XmlTextReader textReader = new XmlTextReader(resultsFileInfo.OpenRead()))
                    {
                        results = (List <TestRecord>)ObjectSerializer.Deserialize(textReader, typeof(List <TestRecord>), null);
                    }
                }
                catch (Exception e)
                {
                    ExecutionEventLog.RecordException(e);
                }
            }
            return(results);
        }
コード例 #10
0
        private static object GetDeserializedObject(XmlReader reader)
        {
            object deserializedObject = null;
            Type   objectType         = null;

            if (reader.HasAttributes && !reader.IsEmptyElement)
            {
                objectType = Type.GetType(reader.GetAttribute("Type"));
                //XmlAttributeOverrides xmlAttributeOverrides = new XmlAttributeOverrides();
                //XmlSerializer xmlSerializer = new XmlSerializer(objectType, xmlAttributeOverrides);

                StringReader stringReader = new StringReader(reader.ReadInnerXml());
                using (XmlTextReader innerReader = new XmlTextReader(stringReader))
                {
                    deserializedObject = ObjectSerializer.Deserialize(innerReader, objectType, null);
                }
                //xmlSerializer.Deserialize(new StringReader(innerXml));
            }

            return(deserializedObject);
        }
コード例 #11
0
        public object Receive()
        {
            var bytesList = new List <byte>();
            var buffer    = new byte[Core.CommonData.NETWORK_BUFFER_SIZE];
            var bytesRead = 0;

            bytesRead = _serverConnector.serverNetworkStream.Read(buffer, 0, buffer.Length);
            var infoMessage = (MessageInfo)ObjectSerializer.Deserialize(buffer);

            for (var i = 0; i <= infoMessage.LengthInBytes / Core.CommonData.NETWORK_BUFFER_SIZE; i++)
            {
                bytesRead = _binaryReader.Read(buffer, 0, buffer.Length);
                for (var j = 0; j < bytesRead; j++)
                {
                    bytesList.Add(buffer[j]);
                }
            }

            Logger.Debug($"Received {bytesList.Count} bytes.");
            return(ObjectSerializer.Deserialize(bytesList.ToArray()));
        }
コード例 #12
0
 /// <summary>
 /// Loads the plugin settings
 /// </summary>
 private void LoadSettings()
 {
     this.settingObject = new Settings();
     if (!File.Exists(this.settingFilename))
     {
         this.SaveSettings();
     }
     else
     {
         Object obj = ObjectSerializer.Deserialize(this.settingFilename, this.settingObject);
         this.settingObject = (Settings)obj;
     }
     if (this.settingObject.UserMacros.Count == 0)
     {
         Macro execScript = new Macro("&Execute Script", new String[1] {
             "ExecuteScript|Development;$(OpenFile)"
         }, String.Empty, Keys.None);
         Macro execCommand = new Macro("E&xecute Command", new String[1] {
             "#$$(Command=RunProcess)|$$(Arguments=cmd.exe)"
         }, String.Empty, Keys.None);
         Macro execfCommand = new Macro("Execu&te Current File", new String[1] {
             "RunProcess|$(CurFile)"
         }, String.Empty, Keys.None);
         Macro runSelected = new Macro("Execute &Selected Text", new String[1] {
             "RunProcess|$(SelText)"
         }, String.Empty, Keys.None);
         Macro browseSelected = new Macro("&Browse Current File", new String[1] {
             "Browse|$(CurFile)"
         }, String.Empty, Keys.None);
         Macro copyTextAsRtf = new Macro("&Copy Text As RTF", new String[1] {
             "ScintillaCommand|CopyRTF"
         }, String.Empty, Keys.None);
         this.settingObject.UserMacros.Add(execScript);
         this.settingObject.UserMacros.Add(execCommand);
         this.settingObject.UserMacros.Add(execfCommand);
         this.settingObject.UserMacros.Add(runSelected);
         this.settingObject.UserMacros.Add(browseSelected);
         this.settingObject.UserMacros.Add(copyTextAsRtf);
     }
 }
コード例 #13
0
        public void Deserialize(string content)
        {
            // remove heading and trailing white spaces
            content = content.Trim();

            // make sure that the parameter starts with ALTREP
            if (!content.StartsWith("CN="))
            {
                throw new ArgumentException("Invalid common name content detected! Property parameter needs to start with CN keyword!");
            }

            // double-quoted parameter value
            if (content.Contains('"'))
            {
                // make sure that the input contains exactly 2 double-quotes
                if (content.Where(x => x == '"').Count() != 2)
                {
                    throw new ArgumentException($"Invalid content ({ content }) detected! The text must be surrounded by double quotes!");
                }

                // determine the start and end indices of the text
                int textStart = content.IndexOf('\"') + 1;
                int textEnd   = content.IndexOf('\"', textStart) - 1;

                // extract the text string from the content
                string textContent = content.Substring(textStart, textEnd - textStart);

                // create a new text value instance from it
                Text = ObjectSerializer.Deserialize <TextValue>(textContent);
            }
            // simple parameter value
            else
            {
                // extract the text string from the content
                string textContent = content.Substring(3, content.Length - 3);

                // create a new text value instance from it
                Text = ObjectSerializer.Deserialize <TextValue>(textContent);
            }
        }
コード例 #14
0
        /// <summary>
        /// Deserialize the JSON element into a QueryResult instance and deserialize each item in the collection into type <typeparamref name="T"/>.
        /// </summary>
        /// <param name="element">The JSON element to be deserialized into a QueryResult.</param>
        /// <param name="objectSerializer">The object serializer instance used to deserialize the items in the collection.</param>
        /// <returns>A collection of query results deserialized into type <typeparamref name="T"/>.</returns>
        internal static QueryResult <T> DeserializeQueryResult(JsonElement element, ObjectSerializer objectSerializer)
        {
            IReadOnlyList <T> items             = default;
            string            continuationToken = default;

            foreach (JsonProperty property in element.EnumerateObject())
            {
                if (property.NameEquals("value"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }

                    var array = new List <T>();

                    foreach (JsonElement item in property.Value.EnumerateArray())
                    {
                        using MemoryStream streamedObject = StreamHelper.WriteJsonElementToStream(item);

                        // To deserialize the stream object into the generic type of T, the provided ObjectSerializer will be used.
                        T obj = (T)objectSerializer.Deserialize(streamedObject, typeof(T), default);
                        array.Add(obj);
                    }

                    items = array;
                    continue;
                }
                if (property.NameEquals("continuationToken"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    continuationToken = property.Value.GetString();
                    continue;
                }
            }
            return(new QueryResult <T>(items, continuationToken));
        }
コード例 #15
0
        public void EnumTest()
        {
            var value = new EnumData {
                Enum = TestEnum.B
            };
            var manager = new SerializationManager(new BuiltInTypesSerializer(), new EnumSerializer <TestEnum>());

            using (var ms = new MemoryStream())
            {
                var s = new ObjectSerializer <EnumData>();
                Assert.True(s.CanSerialize(value, manager));
                using (var bw = new BinaryWriter(ms, Encoding.UTF8, true))
                    s.Serialize(value, bw, manager);
                ms.Position = 0;
                using (var br = new BinaryReader(ms, Encoding.UTF8, true))
                {
                    var res = s.Deserialize(br, manager) as EnumData;
                    Assert.NotNull(res);
                    Assert.Equal(value.Enum, res.Enum);
                }
            }
        }
コード例 #16
0
        public IList <T> HGetList <T>(string hashid, string[] keyList)
        {
            IList <T> list = new List <T>();

            using (var mg = (RedisClient)Manager.GetClient())
            {
                foreach (string key in keyList)
                {
                    byte[] arr = mg.HGet(hashid, key.ToUtf8Bytes());
                    if (arr != null)
                    {
                        ObjectSerializer ser = new ObjectSerializer();
                        var obj = ser.Deserialize(arr);
                        if (obj != null)
                        {
                            list.Add((T)obj);
                        }
                    }
                }
            }
            return(list);
        }
コード例 #17
0
        /// <summary>
        /// Checks if we should process the commands
        /// </summary>
        public static Boolean ShouldProcessCommands()
        {
            Commands commands = new Commands();
            String   filename = Path.Combine(PathHelper.AppDir, "FirstRun.fdb");

            if (File.Exists(filename))
            {
                commands = (Commands)ObjectSerializer.Deserialize(filename, commands);
                if (commands.LatestCommand > Globals.Settings.LatestCommand)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
コード例 #18
0
        /// <summary>
        /// Loads the plugin settings
        /// </summary>
        public void LoadSettings()
        {
            settingObject = new Settings();

            if (!File.Exists(this.settingFilename))
            {
                SaveSettings();
            }
            else
            {
                Object obj = ObjectSerializer.Deserialize(this.settingFilename, settingObject);
                settingObject = (Settings)obj;
            }

#if false
            if (settingObject.DebugFlashPlayerPath == null || settingObject.DebugFlashPlayerPath.Length == 0)
            {
                settingObject.DebugFlashPlayerPath = DetectFlashPlayer();
            }
#endif
            // AddSettingsListeners();
        }
コード例 #19
0
        private void parseRule(string rule)
        {
            if (rule.StartsWith("BY"))
            {
                // parse ByList rule
                var bylistRule = rule.StartsWith("BYDAY") ? (IByListRule)ObjectSerializer.Deserialize <ByDayListRule>(rule) : ObjectSerializer.Deserialize <ByStandardListRule>(rule);
                ListRules[bylistRule.RuleType] = bylistRule;
            }
            else if (rule.StartsWith("COUNT") || rule.StartsWith("UNTIL"))
            {
                // parse delimiter rule
                Delimiter = ObjectSerializer.Deserialize <DelimiterRule>(rule);
            }
            else
            {
                string valueAsString = getPropertyValue(rule);

                if (rule.StartsWith("FREQ"))
                {
                    // parse frequency
                    Frequency = ObjectSerializer.Deserialize <EnumValue <RecurrenceFrequency> >(valueAsString).Value;
                }
                else if (rule.StartsWith("INTERVAL"))
                {
                    // parse interval
                    Interval = ObjectSerializer.Deserialize <IntegerValue>(valueAsString).Value;
                }
                else if (rule.StartsWith("WKST"))
                {
                    // parse week start
                    WeekStart = ObjectSerializer.Deserialize <WeekdayValue>(valueAsString).Day;
                }
                else
                {
                    // TODO: think about soft error handling (e.g. error output in console)
                    throw new ArgumentException($"Invalid recurrence rule part ({ rule }) detected!");
                }
            }
        }
コード例 #20
0
        public void Deserialize_binary_data_should_return_expected_result_when_guid_representation_is_unspecified_and_mode_is_v2(
            [Values(GuidRepresentation.CSharpLegacy, GuidRepresentation.JavaLegacy, GuidRepresentation.PythonLegacy, GuidRepresentation.Standard, GuidRepresentation.Unspecified)]
            GuidRepresentation defaultGuidRepresentation,
            [Values(GuidRepresentation.CSharpLegacy, GuidRepresentation.JavaLegacy, GuidRepresentation.PythonLegacy, GuidRepresentation.Standard, GuidRepresentation.Unspecified)]
            GuidRepresentation readerGuidRepresentation)
        {
#pragma warning disable 618
            var expectedGuidRepresentation = readerGuidRepresentation == GuidRepresentation.Unspecified ? defaultGuidRepresentation : readerGuidRepresentation;
            if (expectedGuidRepresentation == GuidRepresentation.Unspecified)
            {
                throw new SkipException("Skipped because expected GuidRepresentation is Unspecified.");
            }
            BsonDefaults.GuidRepresentationMode = GuidRepresentationMode.V2;
            BsonDefaults.GuidRepresentation     = defaultGuidRepresentation;
            var discriminatorConvention = BsonSerializer.LookupDiscriminatorConvention(typeof(object));
            var subject = new ObjectSerializer(discriminatorConvention, GuidRepresentation.Unspecified);
            var bytes   = new byte[] { 29, 0, 0, 0, 5, 120, 0, 16, 0, 0, 0, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 0 };
            var subType = GuidConverter.GetSubType(expectedGuidRepresentation);
            bytes[11] = (byte)subType;
            var readerSettings = new BsonBinaryReaderSettings();
            if (readerGuidRepresentation != GuidRepresentation.Unspecified)
            {
                readerSettings.GuidRepresentation = readerGuidRepresentation;
            }
            using (var memoryStream = new MemoryStream(bytes))
                using (var reader = new BsonBinaryReader(memoryStream, readerSettings))
                {
                    var context = BsonDeserializationContext.CreateRoot(reader);

                    reader.ReadStartDocument();
                    reader.ReadName("x");
                    var result = subject.Deserialize <object>(context);

                    var guidBytes      = bytes.Skip(12).Take(16).ToArray();
                    var expectedResult = GuidConverter.FromBytes(guidBytes, expectedGuidRepresentation);
                    result.Should().Be(expectedResult);
                }
#pragma warning restore 618
        }
コード例 #21
0
        /// <summary>
        /// Checks if we should process the commands
        /// </summary>
        public static Boolean ShouldProcessCommands()
        {
            Commands commands = new Commands();
            String   filename = Path.Combine(PathHelper.AppDir, "FirstRun.ldb");

            //-----------------------------
            // Create FirstRun.ldb
            //-----------------------------
            //int i = 1;
            //commands.Entries.Add(new Command(i++, "MOVE", @"$(UserAppDir)\;$(UserAppDir).old\"));
            //commands.Entries.Add(new Command(i++, "CREATE", @"$(UserAppDir)\Library\"));
            //commands.Entries.Add(new Command(i++, "CREATE", @"$(UserAppDir)\Plugins\"));
            //commands.Entries.Add(new Command(i++, "CREATE", @"$(UserAppDir)\Projects\"));
            //commands.Entries.Add(new Command(i++, "COPY", @"$(AppDir)\Settings\Languages\;$(UserAppDir)\Settings\Languages\"));
            //commands.Entries.Add(new Command(i++, "COPY", @"$(AppDir)\Snippets\;$(UserAppDir)\Snippets\"));
            //commands.Entries.Add(new Command(i++, "COPY", @"$(AppDir)\Templates\;$(UserAppDir)\Templates\"));
            //commands.Entries.Add(new Command(i++, "COPY", @"$(AppDir)\Settings\Themes\;$(UserAppDir)\Settings\Themes\"));
            //commands.LatestCommand = i;
            //ObjectSerializer.Serialize(filename, commands);
            //-----------------------------

            if (File.Exists(filename))
            {
                commands = (Commands)ObjectSerializer.Deserialize(filename, commands);
                if (commands.LatestCommand > Globals.Settings.LatestCommand)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
コード例 #22
0
ファイル: PluginMain.cs プロジェクト: littlesome/LuaDevelop
 /// <summary>
 /// Loads the plugin settings
 /// </summary>
 public void LoadSettings()
 {
     settingObject = new Settings();
     if (!File.Exists(this.settingFilename))
     {
         this.SaveSettings();
     }
     else
     {
         Object obj = ObjectSerializer.Deserialize(this.settingFilename, settingObject);
         settingObject = (Settings)obj;
     }
     // Try to find svn path from: Tools/sliksvn/
     if (settingObject.SVNPath == "svn.exe")
     {
         String svnCmdPath = @"Tools\sliksvn\bin\svn.exe";
         if (PathHelper.ResolvePath(svnCmdPath) != null)
         {
             settingObject.SVNPath = svnCmdPath;
         }
     }
     // Try to find TortoiseProc path from program files
     if (settingObject.TortoiseSVNProcPath == "TortoiseProc.exe")
     {
         String programFiles = Environment.GetEnvironmentVariable("ProgramFiles");
         String torProcPath  = Path.Combine(programFiles, @"TortoiseSVN\bin\TortoiseProc.exe");
         if (File.Exists(torProcPath))
         {
             settingObject.TortoiseSVNProcPath = torProcPath;
         }
     }
     CheckPathExists(settingObject.SVNPath, "TortoiseSVN (svn)");
     CheckPathExists(settingObject.TortoiseSVNProcPath, "TortoiseSVN (Proc)");
     CheckPathExists(settingObject.GITPath, "TortoiseGit (git)");
     CheckPathExists(settingObject.TortoiseGITProcPath, "TortoiseGIT (Proc)");
     CheckPathExists(settingObject.HGPath, "TortoiseHG (hg)");
     CheckPathExists(settingObject.TortoiseHGProcPath, "TortoiseHG (Proc)");
 }
コード例 #23
0
 /// <summary>
 /// 获取缓存数据
 /// </summary>
 /// <typeparam name="T">泛型类型</typeparam>
 /// <param name="key"></param>
 /// <param name="objectDeserialize">True:获取数据为Byte,转换为T指定类型后返回,False:直接获取缓存数据</param>
 /// <returns></returns>
 public T Get <T>(string key, bool objectDeserialize)
 {
     try
     {
         using (IRedisClient client = GetReadClient())
         {
             if (objectDeserialize)
             {
                 var objSer = new ObjectSerializer();
                 return((T)objSer.Deserialize(client.Get <byte[]>(key)));
             }
             else
             {
                 return(client.Get <T>(key));
             }
         }
     }
     catch (Exception ex)
     {
         LogHelper.Error("key:" + key + " | 错误信息:" + ZException.GetExceptionMessage(ex));
         return(default(T));
     }
 }
コード例 #24
0
 /// <summary>
 /// Applies the file state to a scintilla control
 /// </summary>
 public static void ApplyFileState(ITabbedDocument document, Boolean restorePosition)
 {
     try
     {
         if (!document.IsEditable)
         {
             return;
         }
         String fileStateDir = FileNameHelper.FileStateDir;
         String fileName     = ConvertToFileName(document.FileName);
         String stateFile    = Path.Combine(fileStateDir, fileName + ".ldb");
         if (File.Exists(stateFile))
         {
             StateObject so = new StateObject();
             so = (StateObject)ObjectSerializer.Deserialize(stateFile, so);
             ApplyStateObject(document.SciControl, so, restorePosition);
         }
     }
     catch (Exception ex)
     {
         ErrorManager.ShowError(ex);
     }
 }
コード例 #25
0
 /// <summary>
 /// Load the form state from a setting file and applies it
 /// </summary>
 private void SmartFormLoad(Object sender, EventArgs e)
 {
     this.ApplyTheming();
     if (this.StartPosition == FormStartPosition.CenterParent)
     {
         this.CenterToParent();
     }
     if (!String.IsNullOrEmpty(this.formGuid) && File.Exists(this.FormPropsFile))
     {
         Object obj = ObjectSerializer.Deserialize(this.FormPropsFile, this.formProps);
         this.formProps = (FormProps)obj;
         if (!this.formProps.WindowSize.IsEmpty && this.FormBorderStyle == FormBorderStyle.Sizable)
         {
             this.Size = this.formProps.WindowSize;
         }
     }
     if (!String.IsNullOrEmpty(this.helpLink))
     {
         this.HelpButton         = true;
         this.HelpButtonClicked += new CancelEventHandler(this.SmartFormHelpButtonClick);
     }
     ApplyProps?.Invoke(this);
 }
コード例 #26
0
 private void InitSettings()
 {
     pluginDesc = TextHelper.GetString("Info.Description");
     dataPath   = Path.Combine(PathHelper.DataDir, "ASCompletion");
     if (!Directory.Exists(dataPath))
     {
         Directory.CreateDirectory(dataPath);
     }
     settingsFile  = Path.Combine(dataPath, "Settings.fdb");
     settingObject = new GeneralSettings();
     if (!File.Exists(settingsFile))
     {
         // default settings
         settingObject.JavadocTags    = GeneralSettings.DEFAULT_TAGS;
         settingObject.PathToFlashIDE = Commands.CallFlashIDE.FindFlashIDE();
         SaveSettings();
     }
     else
     {
         Object obj = ObjectSerializer.Deserialize(settingsFile, settingObject);
         settingObject = (GeneralSettings)obj;
     }
 }
コード例 #27
0
 /// <summary>
 /// Loads the plugin settings
 /// </summary>
 public void LoadSettings()
 {
     this.settingObject = new Settings();
     this.SaveSettings();
     if (!File.Exists(this.settingFilename))
     {
         this.SaveSettings();
     }
     else
     {
         object obj = ObjectSerializer.Deserialize(this.settingFilename, this.settingObject);
         this.settingObject = (Settings)obj;
     }
     this.preprocessorLocation = this.settingObject.ParserPath;
     //String dataPath = Path.Combine(PathHelper.UserAppDir, this.settingObject.ParserPath);
     //if (!Directory.Exists(dataPath)) Directory.CreateDirectory(dataPath);
     //this.projectRoot = dataPath;
     //dataPath = Path.Combine(PathHelper.TemplateDir, "rsx-templates");
     ////if (!Directory.Exists(dataPath)) this.InstallTemplates(dataPath);
     //this.preprocessorLocation = dataPath;
     //this.nsxRoot = Path.Combine(PathHelper.UserAppDir, "lib");
     //if (!Directory.Exists(dataPath)) Directory.CreateDirectory(dataPath);
 }
コード例 #28
0
        public static void List(RedisClient redis)
        {
            var           ser          = new ObjectSerializer();
            List <Person> userinfoList = new List <Person> {
                new Person {
                    Name = "露西", Age = 1
                },
                new Person {
                    Name = "玛丽", Age = 3
                },
            };

            redis.Set <byte[]>("userinfolist_serialize", ser.Serialize(userinfoList));
            List <Person> userList = ser.Deserialize(redis.Get <byte[]>("userinfolist_serialize")) as List <Person>;

            userList.ForEach(i =>
            {
                Console.WriteLine("name=" + i.Name + "   age=" + i.Age);
            });
            Console.WriteLine(userList);
            Console.ReadLine();
            //释放内存
        }
コード例 #29
0
        static void simpleRedisGetSet()
        {
            string      host        = "localhost";
            string      elementKey  = "testKeyRedis";
            RedisClient redisclient = new RedisClient(host);

            redisclient.Remove(elementKey);
            var storeMembers = new List <string> {
                "asd", "dsd", "bb"
            };

            // storeMembers.ForEach(x=>redisclient.AddItemToList(elementKey,x));

            redisclient.AddRangeToList(elementKey, storeMembers);
            var members = redisclient.GetAllItemsFromList(elementKey);
            var list    = redisclient.Lists[elementKey];

            list.Clear();
            var  ser    = new ObjectSerializer();
            bool result = redisclient.Set <byte[]>(elementKey, ser.Serialize(storeMembers));

            if (result)
            {
                var resultlist = ser.Deserialize(redisclient.Get <byte[]>(elementKey));
            }
            members.ForEach(s => Console.WriteLine("list:" + s));
            //   Console.WriteLine("index2:"+redisclient.GetItemFromList(elementKey,1));
            //if (redisclient.Get<string>(elementKey) == null)
            //{
            //    redisclient.Set(elementKey, "defaultValue");
            //}
            //else {
            //    redisclient.Set(elementKey, "new default value");
            //}
            //Console.WriteLine("redise:value:"+redisclient.Get<string>(elementKey));
            Console.WriteLine(redisclient.Info);
        }
コード例 #30
0
        public static void LoadMetaDatabases(List <GallerySource> sources)
        {
            foreach (GallerySource source in sources)
            {
                try
                {
                    RaiseStatusUpdatedEvent("Loading source (" + source.Path + ")...");
                    string databaseFileName = Path.ChangeExtension(source.ID, DATABASE_FILE_EXTENSION);
                    string databaseFilePath = Path.Combine(ObjectPool.CompleteDatabaseLocation, databaseFileName);
                    if (File.Exists(databaseFilePath))
                    {
                        using (ZipFile sourceDatabase = ZipFile.Read(databaseFilePath))
                        {
                            MemoryStream memoryStream = new MemoryStream();
                            ZipEntry     zipEntry     = sourceDatabase[Path.ChangeExtension(source.ID, METAFILE_FILE_EXTENSION)];
                            zipEntry.Extract(memoryStream);
                            memoryStream.Position = 0;
                            StreamReader reader = new StreamReader(memoryStream);

                            string   objectPrefix;
                            string[] deserializedObject = ObjectSerializer.Deserialize(reader.ReadLine(), out objectPrefix);
                            if (objectPrefix != "GV")
                            {
                                throw new Exception("Failed to deserialize source database; gallery version missing");
                            }
                            GalleryVersion version = new GalleryVersion(deserializedObject);

                            DeserializeSource(reader, source);

                            reader.Close();
                            memoryStream.Close();
                        }
                    }
                }
                catch { }
            }
        }