Ejemplo n.º 1
0
 public Property(string name, PropertyDirectory value)
 {
     if (string.IsNullOrWhiteSpace(name))
     {
         throw new System.ArgumentNullException(nameof(name));
     }
     this.Name      = name;
     this.directory = value ?? throw new System.ArgumentNullException(nameof(value));
     this.value     = null;
     this.Type      = PropertyType.Directory;
 }
Ejemplo n.º 2
0
        public string Serialize()
        {
            if (string.IsNullOrWhiteSpace(Name))
            {
                throw new System.InvalidOperationException("Property name is not set");
            }

            return(Type switch
            {
                PropertyType.String => Serialize((string)Value),
                PropertyType.Integer => Serialize((int)Value),
                PropertyType.DbRef => Serialize((Dbref)Value, 0),
                PropertyType.Lock => Serialize((Lock)Value, 0),
                PropertyType.Float => Serialize((float)Value),
                PropertyType.Directory => PropertyDirectory.Serialize((PropertyDirectory)Value),
                _ => throw new System.InvalidOperationException($"Unknown property type for {Name}: {Type}"),
            });
Ejemplo n.º 3
0
        public void AddInPath(string name, Property property)
        {
            if (name.Contains('/'))
            {
                var parts = name.Split('/');
                if (parts.Length > 1 && parts[0].Length > 0 && parts[1].Length > 1)
                {
                    var propdirTitle = parts[0];
                    PropertyDirectory subdir;
                    if (this.ContainsKey(propdirTitle))
                    {
                        subdir = (PropertyDirectory)this[propdirTitle].directory !;
                        if (subdir == null)
                        {
                            throw new System.InvalidOperationException();
                        }
                    }
                    else
                    {
                        subdir = new PropertyDirectory();
                        this.Add(propdirTitle, subdir);
                    }

                    var remainingTitle = name[(propdirTitle.Length + 1)..];