Example #1
0
        private void CollectPostedActions()
        {
            var postedPath = Path.Combine(this.workingPath, DomainLogger.PostedFileName);

            using (var reader = XmlReader.Create(postedPath, readerSettings))
            {
                reader.Read();
                while (reader.EOF != true)
                {
                    DomainActionBase actionObject = null;
                    if (reader.Name == typeof(NewRowAction).Name)
                    {
                        actionObject = DataContractSerializerUtility.Read <NewRowAction>(reader);
                    }
                    else if (reader.Name == typeof(RemoveRowAction).Name)
                    {
                        actionObject = DataContractSerializerUtility.Read <RemoveRowAction>(reader);
                    }
                    else if (reader.Name == typeof(SetRowAction).Name)
                    {
                        actionObject = DataContractSerializerUtility.Read <SetRowAction>(reader);
                    }
                    else if (reader.Name == typeof(SetPropertyAction).Name)
                    {
                        actionObject = DataContractSerializerUtility.Read <SetPropertyAction>(reader);
                    }
                    else if (reader.Name == typeof(JoinAction).Name)
                    {
                        actionObject = DataContractSerializerUtility.Read <JoinAction>(reader);
                    }
                    else if (reader.Name == typeof(DisjoinAction).Name)
                    {
                        actionObject = DataContractSerializerUtility.Read <DisjoinAction>(reader);
                    }
                    else if (reader.Name == typeof(KickAction).Name)
                    {
                        actionObject = DataContractSerializerUtility.Read <KickAction>(reader);
                    }
                    else if (reader.Name == typeof(SetOwnerAction).Name)
                    {
                        actionObject = DataContractSerializerUtility.Read <SetOwnerAction>(reader);
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }

                    this.lastID = actionObject.ID;

                    if (this.completedActions.Contains(actionObject.ID) == false)
                    {
                        continue;
                    }

                    this.postedActions.Add(actionObject);
                }
            }
        }
Example #2
0
        public void Initialize()
        {
            this.cremaHost.Debug("Load user data...");

            if (File.Exists(this.userFilePath) == true)
            {
                var serializationInfo = DataContractSerializerUtility.Read <UserContextSerializationInfo>(this.userFilePath);

                foreach (var item in serializationInfo.Categories)
                {
                    if (item == this.Root.Path)
                    {
                        continue;
                    }
                    this.Categories.Prepare(item);
                }

                for (var i = 0; i < serializationInfo.Users.Length; i++)
                {
                    var item = serializationInfo.Users[i];
                    if (serializationInfo.Version == null)
                    {
                        item.BanInfo = (BanSerializationInfo)BanInfo.Empty;
                    }
                    var user = this.Users.AddNew(item.ID, item.CategoryPath);
                    user.Initialize((UserInfo)item, (BanInfo)item.BanInfo);
                    user.Password = UserContext.StringToSecureString(item.Password);
                }
            }
            else
            {
                var user     = this.Users.AddNew(Authentication.AdminID, PathUtility.Separator);
                var userInfo = new UserInfo()
                {
                    ID           = Authentication.AdminID,
                    Name         = Authentication.AdminName,
                    CategoryPath = PathUtility.Separator,
                    Authority    = Authority.Admin,
                };
                user.Initialize(userInfo, BanInfo.Empty);
                user.Password = UserContext.StringToSecureString(Authentication.AdminID.Encrypt());
            }

            this.cremaHost.Debug("Loading complete!");
        }
Example #3
0
        public object Deserialize(string itemPath, Type type, ObjectSerializerSettings settings)
        {
            if (type == typeof(CremaDataTable))
            {
                throw new NotImplementedException();
            }
            else if (type == typeof(CremaDataType))
            {
                var extension = settings.Extension != string.Empty ? settings.Extension : CremaSchema.SchemaExtension;
                var filename  = itemPath + extension;
                var dataSet   = new CremaDataSet();
                var dataType  = CremaDataType.ReadSchema(filename);
                dataSet.Types.Add(dataType);
                return(dataType);
            }
            else if (type == typeof(CremaDataSet))
            {
                if (settings is CremaDataSetSerializerSettings props)
                {
                    var dataSet    = CremaDataSet.Create(props.SignatureDateProvider);
                    var typePaths  = props.TypePaths.Select(item => item + CremaSchema.SchemaExtension).ToArray();
                    var tablePaths = props.TablePaths.Select(item => item + CremaSchema.XmlExtension).ToArray();

                    dataSet.ReadMany(typePaths, tablePaths, props.SchemaOnly);
                    dataSet.AcceptChanges();

                    return(dataSet);
                }
                else
                {
                    return(CremaDataSet.ReadFromDirectory(itemPath));
                }
            }
            else
            {
                var extension = settings.Extension != string.Empty ? settings.Extension : CremaSchema.XmlExtension;
                var filename  = itemPath + extension;
                return(DataContractSerializerUtility.Read(filename, type));
            }
        }