Example #1
0
        /// <summary>
        /// <icu/> Loads a new resource bundle for the given base name, locale and assembly.
        /// Optionally will disable loading of fallback bundles.
        /// </summary>
        /// <param name="baseName">String containing the name of the data package.
        /// If null the default ICU package name is used.</param>
        /// <param name="localeName">The locale for which a resource bundle is desired.</param>
        /// <param name="root">The class object from which to load the resource bundle.</param>
        /// <param name="disableFallback">Disables loading of fallback lookup chain.</param>
        /// <exception cref="MissingManifestResourceException">If no resource bundle for the specified base name can be found.</exception>
        /// <returns>A resource bundle for the given base name and locale.</returns>
        /// <stable>ICU 3.0</stable>
        protected static UResourceBundle InstantiateBundle(string baseName, string localeName,
                                                           Assembly root, bool disableFallback)
        {
            RootType rootType = GetRootType(baseName, root);

            switch (rootType)
            {
            case RootType.ICU:
                return(ICUResourceBundle.GetBundleInstance(baseName, localeName, root, disableFallback));

            case RootType.DotNet:
                return(ResourceBundleWrapper.GetBundleInstance(baseName, localeName, root,
                                                               disableFallback));

            case RootType.Missing:
            default:
                UResourceBundle b;
                try
                {
                    b = ICUResourceBundle.GetBundleInstance(baseName, localeName, root,
                                                            disableFallback);
                    SetRootType(baseName, RootType.ICU);
                }
                catch (MissingManifestResourceException)
                {
                    b = ResourceBundleWrapper.GetBundleInstance(baseName, localeName, root,
                                                                disableFallback);
                    SetRootType(baseName, RootType.DotNet);
                }
                return(b);
            }
        }
Example #2
0
        public void MapBoxedMembers()
        {
            Mapper mapper = new Mapper();

            RootType source = new RootType
            {
                Value = new SourceType
                {
                    Id   = 1,
                    Name = "BoxedSourceType"
                }
            };

            RootType target = new RootType
            {
                Value = new TargetType
                {
                    Id   = 2,
                    Name = "BoxedTargetType"
                }
            };

            RootType result = mapper.Map(source, target);

            Assert.NotNull(result);
            Assert.Equal("BoxedSourceType", ((TargetType)result.Value).Name);
            Assert.Equal(1, ((TargetType)result.Value).Id);
        }
Example #3
0
        public bool SetRoot(RootType rt, string path)
        {
            switch (rt)
            {
            case RootType.CLASSROOT:
                rootkey = Registry.ClassesRoot;
                break;

            case RootType.CURRENTUSER:
                rootkey = Registry.CurrentUser;
                break;

            case RootType.LOCALMACHINE:
                rootkey = Registry.LocalMachine;
                break;

            case RootType.USERS:
                rootkey = Registry.Users;
                break;

            case RootType.CURRENTCONFIG:
                rootkey = Registry.CurrentConfig;
                break;

            default:
                break;
            }
            try
            {
                rootkey.CreateSubKey(path, RegistryKeyPermissionCheck.ReadWriteSubTree);
                defaultRoot = rootkey.OpenSubKey(path, true);
                return(true);
            }
            catch { return(false); }
        }
        public void SerializationTests_Json_InnerTypes_NoTypeNameHandling()
        {
            var original  = new RootType();
            var str       = JsonConvert.SerializeObject(original);
            var jsonDeser = JsonConvert.DeserializeObject <RootType>(str);

            // Here we don't use TypeNameHandling.All setting, therefore the full type information is not preserved.
            // As a result JsonConvert leaves the inner types as JObjects after Deserialization.
            Assert.Equal(typeof(InnerType), original.MyDictionary["obj1"].GetType());
            Assert.Equal(typeof(JObject), jsonDeser.MyDictionary["obj1"].GetType());
            // The below Assert actualy fails since jsonDeser has JObjects instead of InnerTypes!
            // Assert.Equal(original, jsonDeser);

            // If we now take this half baked object: RootType at the root and JObject in the leaves
            // and pass it through .NET binary serializer it would fail on this object since JObject is not marked as [Serializable]
            // and therefore .NET binary serializer cannot serialize it.

            // If we now take this half baked object: RootType at the root and JObject in the leaves
            // and pass it through Orleans serializer it would work:
            // RootType will be serialized with Orleans custom serializer that will be generated since RootType is defined
            // in GrainInterfaces assembly and markled as [Serializable].
            // JObject that is referenced from RootType will be serialized with JsonSerialization_Example2 below.

            var orleansJsonDeser = SerializationManager.RoundTripSerializationForTesting(jsonDeser);

            Assert.Equal(typeof(JObject), orleansJsonDeser.MyDictionary["obj1"].GetType());
            // The below assert fails, but only since JObject does not correctly implement Equals.
            //Assert.Equal(jsonDeser, orleansJsonDeser);
        }
    protected BaseView(string prefabName, RootType type, ViewMode mode)
    {
        //ViewName = this.GetType().ToString();
        ViewName = prefabName;
        RootType = type;
        Mode     = mode;

        CreateUI();
    }
Example #6
0
        public ChecksumCollection(string rootPath, RootType rootType)
        {
            RootType = rootType;
            var fullPath = Path.GetFullPath(rootPath);

            fullPath   = Path.TrimEndingDirectorySeparator(fullPath);
            RootParent = Path.GetDirectoryName(fullPath);
            Root       = Path.GetFileName(fullPath);
        }
Example #7
0
 public MegaNzNode(string Name, string ID, string parentid, long Size, RootType type, DateTime mod_d, INodeCrypto keyDeCrypt) : base(keyDeCrypt)
 {
     this.name     = Name;
     this.id       = ID;
     this.parentid = parentid;
     this.size     = Size;
     this.type     = type;
     this.mod_d    = mod_d;
 }
		public void Test()
		{
			TypeAccessor ta = TypeAccessor.GetAccessor(typeof(RootType));

			PropertyDescriptorCollection col  = ta.CreateExtendedPropertyDescriptors(null, null);
			PropertyDescriptor           prop = col["Type1+Type2+Name"];

			RootType obj = new RootType();

			object value = prop.GetValue(obj);

			Assert.AreEqual("test", value);
		}
        public void Test()
        {
            TypeAccessor ta = TypeAccessor.GetAccessor(typeof(RootType));

            PropertyDescriptorCollection col  = ta.CreateExtendedPropertyDescriptors(null, null);
            PropertyDescriptor           prop = col["Type1+Type2+Name"];

            RootType obj = new RootType();

            object value = prop.GetValue(obj);

            Assert.AreEqual("test", value);
        }
Example #10
0
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="databaseOptions">The database options</param>
        /// <param name="database">The database that contains the mapped table</param>
        /// <param name="columns">The columns of the tables</param>
        /// <param name="joins">The joins</param>
        /// <param name="tables">The tables</param>
        protected QueryMap(BaseDatabaseOptionsDataModel databaseOptions, IDbProviderDatabase database, IEnumerable <IDbProviderTable> tables, IEnumerable <IDbProviderColumn> columns, IEnumerable <JoinMap> joins) : base()
        {
            Database        = database ?? throw new ArgumentNullException(nameof(database));
            Joins           = joins ?? Enumerable.Empty <JoinMap>();
            DatabaseOptions = databaseOptions ?? throw new ArgumentNullException(nameof(databaseOptions));
            Tables          = tables.NotNullOrEmpty();
            Columns         = columns.NotNullOrEmpty();

            PropertyShortcodes = new Lazy <IEnumerable <PropertyShortcode> >(() =>
            {
                return(RootType.GetProperties().Select(x => new PropertyShortcode(x.Name, Blue, "Shortcodes", null, x, null)).ToList());
            });
        }
Example #11
0
        // GET: RootTypes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RootType rootType = db.GetRootTypeById(Convert.ToInt32(id));

            if (rootType == null)
            {
                return(HttpNotFound());
            }
            return(View(rootType));
        }
Example #12
0
        private static void GenerateBin(FlatBufferBuilder fb)
        {
            StringOffset carStrOff = fb.CreateString("这是张三第一辆车");
            Offset <Car> carOff    = Car.CreateCar(fb, 10001, (long)123456321, carStrOff);
            var          carlist   = new Offset <Car> [1];

            carlist[0] = carOff;
            VectorOffset carlistOff = Person.CreateCarListVector(fb, carlist);

            StringOffset    nameOff = fb.CreateString("张三");
            Offset <Person> p1Off   = Person.CreatePerson(fb, 1001, nameOff, (long)1222, false, carlistOff);

            StringOffset carStr1Off = fb.CreateString("这是李四第一辆车");
            StringOffset carStr2Off = fb.CreateString("这是李四第一辆车");
            StringOffset carStr3Off = fb.CreateString("这是李四第一辆车");

            StringOffset nameStr1Off = fb.CreateString("李四");

            Offset <Car> car1 = Car.CreateCar(fb, 10001, (long)123456001, carStr1Off);
            Offset <Car> car2 = Car.CreateCar(fb, 10002, (long)123456002, carStr2Off);
            Offset <Car> car3 = Car.CreateCar(fb, 10003, (long)123456003, carStr3Off);

            var carLists = new Offset <Car> [3];

            carLists[0] = car1;
            carLists[1] = car2;
            carLists[2] = car3;
            VectorOffset carlist2Off = Person.CreateCarListVector(fb, carLists);

            Offset <Person> p2Off = Person.CreatePerson(fb, 1002, nameStr1Off, (long)1123, false, carlist2Off);


            var items = new Offset <Person> [2];

            items[0] = p1Off;
            items[1] = p2Off;

            VectorOffset itemsOff = RootType.CreateItemsVector(fb, items);

            Offset <RootType> rootOff = RootType.CreateRootType(fb, itemsOff, 404, (long)20180904);

            RootType.FinishRootTypeBuffer(fb, rootOff);

            //RootType rootType = RootType.GetRootAsRootType(fb.DataBuffer);
            //Console.WriteLine("time = " + rootType.Time.ToString());
            //Console.WriteLine("stateId = " + rootType.Stateid.ToString());
            Storage(fb);
        }
Example #13
0
        private static void ReadData(string path)
        {
            //FileStream file = null;
            //BinaryReader br = null;
            try
            {
                //file = new FileStream(path, FileMode.Open);
                //byte[] data = new byte[(int)file.Length];
                //br = new BinaryReader(file);
                //br.Read(data, 0, (int)file.Length);

                byte[] data = File.ReadAllBytes(path);

                ByteBuffer byteBuffer = new ByteBuffer(data);
                //byteBuffer.Position = 80;
                //byteBuffer.Position = ByteBufferUtil.GetSizePrefix(byteBuffer);
                RootType rootType = RootType.GetRootAsRootType(byteBuffer);
                Console.WriteLine("time = " + rootType.Time.ToString());
                Console.WriteLine("stateId = " + rootType.Stateid.ToString());

                int count = rootType.ItemsLength;
                Console.WriteLine("items.length = " + rootType.ItemsLength);
                for (int i = 0; i < count; i++)
                {
                    Person item = (Person)rootType.Items(i);
                    Console.WriteLine("item " + (i + 1) + "'s Id:" + item.Id);
                    Console.WriteLine("item " + (i + 1) + "'s name:" + item.Name);
                    Console.WriteLine("item " + (i + 1) + "'s code:" + item.Code);
                    Console.WriteLine("item " + (i + 1) + "'s carCount:" + item.CarListLength);
                    for (int j = 0; j < item.CarListLength; j++)
                    {
                        Car car = (Car)item.CarList(j);
                        Console.WriteLine("item " + (i + 1) + "'s 第" + (j + 1) + "个 car Id:" + car.Id);
                        Console.WriteLine("item " + (i + 1) + "'s 第" + (j + 1) + "个 car number:" + car.Number);
                        Console.WriteLine("item " + (i + 1) + "'s 第" + (j + 1) + "个 car des:" + car.Describle);
                    }
                }
            }
            catch (Exception e)
            {
            }
            finally {
                //br.Close();
                //file.Close();
            }
        }
        public void SerializationTests_Json_InnerTypes_TypeNameHandling()
        {
            var original  = new RootType();
            var str       = JsonConvert.SerializeObject(original, JsonSerializationExample2.Settings);
            var jsonDeser = JsonConvert.DeserializeObject <RootType>(str, JsonSerializationExample2.Settings);

            // JsonConvert fully deserializes the object back into RootType and InnerType since we are using TypeNameHandling.All setting.
            Assert.Equal(typeof(InnerType), original.MyDictionary["obj1"].GetType());
            Assert.Equal(typeof(InnerType), jsonDeser.MyDictionary["obj1"].GetType());
            Assert.Equal(original, jsonDeser);

            // Orleans's SerializationManager also deserializes everything correctly, but it serializes it into its own binary format
            var orleansDeser = SerializationManager.RoundTripSerializationForTesting(original);

            Assert.Equal(typeof(InnerType), jsonDeser.MyDictionary["obj1"].GetType());
            Assert.Equal(original, orleansDeser);
        }
    //public void SetHead(Transform head)
    //{
    //	this.headObj = head;
    //}

    public static void SetRoot(Transform target, RootType type)
    {
        if (RootType.ScreenRoot == type)
        {
            target.SetParent(ScreenRoot);
        }
        else if (RootType.WorldRoot == type)
        {
            target.SetParent(WorldRoot);
        }
        else if (RootType.TraceRoot == type)
        {
            target.SetParent(TraceRoot);
        }
        else if (RootType.FollowRoot == type)
        {
            target.SetParent(FollowRoot);
        }
    }
Example #16
0
            // Gets the physical path of a directory entry type
            public static string GetPath(RootType rootType, string machine)
            {
                string path;

                switch (rootType)
                {
                case RootType.AppPool:
                    path = "IIS://" + machine + "/W3SVC/AppPools";
                    break;

                case RootType.IIS:
                    path = "IIS://" + machine + "/W3SVC/1/ROOT";
                    break;

                default:
                    return(null);
                }

                return(path);
            }
Example #17
0
    public void OnInitialised()
    {
        //MyPaddock.Parent.ChildPaddocks
        PotSWUptake = new double[ll15_dep.Length];
        SWUptake    = new double[ll15_dep.Length];
        PotNUptake  = new double[ll15_dep.Length];
        NUptake     = new double[ll15_dep.Length];

        UnderstoryPotSWUptake = new double[ll15_dep.Length];
        UnderstorySWUptake    = new double[ll15_dep.Length];
        UnderstoryPotNUptake  = new double[ll15_dep.Length];
        UnderstoryNUptake     = new double[ll15_dep.Length];

        for (int i = 0; i < ll15_dep.Length; i++)
        {
            RootType R = new RootType();
            Roots.Add(R);
            Roots[i].Mass = 0.1;
            Roots[i].N    = Roots[i].Mass * RootNConcentration.Value / 100;
        }

        for (int i = 0; i < (int)InitialFrondNumber.Value; i++)
        {
            FrondType F = new FrondType();
            F.Age  = ((int)InitialFrondNumber.Value - i) * FrondAppRate.Value;
            F.Area = SizeFunction(F.Age);
            F.Mass = F.Area / SpecificLeafArea.Value;
            F.N    = F.Mass * FrondCriticalNConcentration.Value / 100.0;
            Fronds.Add(F);
            CumulativeFrondNumber += 1;
        }
        for (int i = 0; i < (int)InitialFrondNumber.Value + 60; i++)
        {
            BunchType B = new BunchType();
            B.FemaleFraction = FemaleFlowerFraction.Value;
            Bunches.Add(B);
        }


        RootDepth = InitialRootDepth;
    }
Example #18
0
            // Gets the root of a directory entry type
            public static DirectoryEntry GetRoot(RootType rootType, string machine)
            {
                string path = GetPath(rootType, machine);

                DirectoryEntry root;

                if (!string.IsNullOrEmpty(IISTools.Username))
                {
                    root = new DirectoryEntry(path, IISTools.Username, IISTools.Password);
                }
                else
                {
                    root = new DirectoryEntry(path);
                }

                if (root == null)
                {
                    throw new Exception("Could not get the directory entry. Please check if you have enough access rights to complete this operation");
                }

                return(root);
            }
        public void Can_write_polymorphic_records()
        {
            IList <RootType> insertedEntities = new RootType[]
            {
                new DerivedType1(),
                new SubDerivedType1(),
                new SubDerivedType2()
            }
            .OrderBy(rootType => rootType.StringProperty)
            .ToList();

            _testMongoDbContext.AddRange(insertedEntities);
            _testMongoDbContext.SaveChanges(acceptAllChangesOnSuccess: true);
            IList <RootType> queriedEntities = _testMongoDbContext.RootTypes
                                               .OrderBy(rootType => rootType.StringProperty)
                                               .ToList();

            Assert.Equal(insertedEntities.Count, queriedEntities.Count);
            for (var i = 0; i < insertedEntities.Count; i++)
            {
                Assert.Equal(insertedEntities[i], queriedEntities[i]);
            }
        }
Example #20
0
        static INode GetRoot(string Email, RootType type)
        {
            switch (type)
            {
            case RootType.Directory:
            case RootType.File:
            case RootType.Inbox:
                throw new Exception("That isn't root.");

            case RootType.Root:
            case RootType.Trash:
                MegaApiClient client = GetClient(Email);
                foreach (INode n in client.GetNodes().Where <INode>(n => n.Type == RootType.Root))
                {
                    if (n.Type == RootType.Root)
                    {
                        return(n);
                    }
                }
                break;
            }
            throw new Exception("Can't find " + type.ToString());
        }
Example #21
0
        /// <summary>
        /// Registers the rule with the current <see cref="ModelContext"/>.
        /// </summary>
        public void Register(ModelType rootType = null)
        {
            // Determine if the rule is be registered for a specific root model type
            if (rootType != null)
            {
                if (this.rootType != null)
                {
                    throw new InvalidOperationException("Rules cannot be explicitly registered for more than one model type.");
                }
                this.rootType = rootType;
            }

            // Raise the Initialization event the first time the rule is registered
            if (Initialize != null)
            {
                Initialize(this, EventArgs.Empty);
                Initialize = null;
            }

            // Default the invocation type to PropertyChanged if none were assigned
            if ((int)InvocationTypes == 1)
            {
                InvocationTypes = RuleInvocationType.PropertyChanged;
            }

            // Automatically detect predicates if none were specified
            if (Predicates == null && ((InvocationTypes & (RuleInvocationType.PropertyChanged | RuleInvocationType.PropertyGet)) > 0))
            {
                SetPredicates(GetPredicates());
            }

            // Track and validate uniqueness of condition types
            HashSet <ConditionType> conditionTypes = RootType.GetExtension <HashSet <ConditionType> >();

            foreach (var conditionType in ConditionTypes)
            {
                if (conditionTypes.Contains(conditionType))
                {
                    throw new InvalidOperationException("Registered condition types must be unique for each model type: " + conditionType.Code);
                }
                conditionTypes.Add(conditionType);
            }

            // Track the rule registration for the root model type
            List <Rule> rules = RootType.GetExtension <List <Rule> >();

            rules.Add(this);

            // Do not perform model type event registration if the rule is not supposed to execute on the server
            if ((ExecutionLocation & RuleExecutionLocation.Server) == 0)
            {
                return;
            }

            // Init Invocation
            if ((InvocationTypes & RuleInvocationType.InitExisting) == RuleInvocationType.InitExisting ||
                (InvocationTypes & RuleInvocationType.InitNew) == RuleInvocationType.InitNew)
            {
                RootType.Init += (sender, e) =>
                {
                    if (((InvocationTypes & RuleInvocationType.InitExisting) == RuleInvocationType.InitExisting && !e.Instance.IsNew) ||
                        ((InvocationTypes & RuleInvocationType.InitNew) == RuleInvocationType.InitNew && e.Instance.IsNew))
                    {
                        Invoke(e.Instance, e);
                    }
                };
            }

            // Property Get Invocation
            if ((InvocationTypes & RuleInvocationType.PropertyGet) == RuleInvocationType.PropertyGet)
            {
                // Subscribe to property get notifications for all return values
                RootType.PropertyGet += (sender, e) =>
                {
                    // Determine if the rule is responsible for calculating the property being accessed
                    if (ReturnValues.Contains(e.Property.Name))
                    {
                        // Get the rule manager for the current instance
                        var manager = e.Instance.GetExtension <RuleManager>();

                        // Determine if the rule needs to be run
                        if ((e.IsFirstAccess && (!e.Property.IsPersisted || e.Instance.IsNew || manager.IsPendingInvocation(this))) || manager.IsPendingInvocation(this))
                        {
                            // Invoke the rule
                            Invoke(e.Instance, e);

                            // Mark the rule state as no longer requiring invocation
                            manager.SetPendingInvocation(this, false);
                        }
                    }
                };

                if (!InvocationTypes.HasFlag(RuleInvocationType.SuppressPropertyChanged))
                {
                    // Subscribe to property change notifications for all rule predicates
                    foreach (string predicate in Predicates)
                    {
                        RootType.GetPath(predicate).Change += (sender, e) =>
                        {
                            // Only invoke the rule if the instance is of the same type as the rule root type
                            if (RootType.IsInstanceOfType(e.Instance))
                            {
                                // Get the rule manager for the current instance
                                var manager = e.Instance.GetExtension <RuleManager>();

                                // Mark the rule state as requiring invocation
                                if (manager.SetPendingInvocation(this, true))
                                {
                                    // Raise property change notifications
                                    foreach (var property in ReturnValues)
                                    {
                                        e.Instance.Type.Properties[property].NotifyPathChange(e.Instance);
                                    }
                                }
                            }
                        };
                    }
                }

                // Mark the properties as calculated to denote that they are return values of a rule
                foreach (var property in ReturnValues)
                {
                    var prop = RootType.Properties[property];
                    if (prop != null)
                    {
                        prop.IsCalculated = true;
                    }
                }
            }

            // Property Change Invocation
            if ((InvocationTypes & RuleInvocationType.PropertyChanged) == RuleInvocationType.PropertyChanged)
            {
                // Subscribe to property change notifications for all rule predicates
                foreach (string predicate in Predicates)
                {
                    RootType.GetPath(predicate).Change += (sender, e) =>
                    {
                        // Only invoke the rule if the instance is of the same type as the rule root type
                        if (RootType.IsInstanceOfType(e.Instance))
                        {
                            // Get the rule manager for the current instance
                            var manager = e.Instance.GetExtension <RuleManager>();

                            // Register the rule to run if it is not already registered
                            if (manager.SetPendingInvocation(this, true))
                            {
                                // Invoke the rule when the last model event scope exits
                                ModelEventScope.OnExit(() =>
                                {
                                    // Mark the rule state as no longer requiring invocation
                                    manager.SetPendingInvocation(this, false);

                                    // Invoke the rule
                                    Invoke(e.Instance, e);
                                });
                            }
                        }
                    };
                }
            }

            // Allow subclasses to perform additional registration logic
            OnRegister();
        }
Example #22
0
 public SampleView(string prefabName, RootType type, ViewMode mode) : base(prefabName, type, mode)
 {
 }
Example #23
0
        internal bool IsClosingOther(UIInfoAttribute info)
        {
            UIRootInfoAttribute rootInfo = RootType.GetCustomAttribute <UIRootInfoAttribute>();

            return(rootInfo.IsClosingOther(info.RootType));
        }
Example #24
0
 private static void SetRootType(string baseName, RootType rootType)
 {
     ROOT_CACHE[baseName] = rootType;
 }
Example #25
0
 public MegaNzNode(string Name, string ID, string parentid, long Size, RootType type, DateTime mod_d) : this(Name, ID, parentid, Size, type, mod_d, null)
 {
 }
Example #26
0
 // <summary>
 // Try get the new property for the supplied propertyRef
 // </summary>
 // <param name="propertyRef"> property reference (on the old type) </param>
 // <param name="throwIfMissing"> throw if the property is not found </param>
 // <param name="newProperty"> the corresponding property on the new type </param>
 internal bool TryGetNewProperty(PropertyRef propertyRef, bool throwIfMissing, out md.EdmProperty newProperty)
 {
     return(RootType.TryGetNewProperty(propertyRef, throwIfMissing, out newProperty));
 }
Example #27
0
    /// <summary>
    /// ルート読み込み
    /// </summary>
    void rootsLoad()
    {
        int chip_x = mapchip.chip_num_x;
        int chip_y = mapchip.chip_num_y;

        rootmax = 0;
        while (true)
        {
            var readtext = Resources.Load <TextAsset>("StageData/"
                                                      + mapchip.select_map_name
                                                      + "_Enemy" + enemynumber
                                                      + "Root" + rootmax + "Data");


            if (readtext == null)
            {
                break;
            }

            int[][] loadrootnums = new int[chip_y][];
            for (int y = 0; y < chip_y; y++)
            {
                loadrootnums[y] = new int[chip_x];
            }

            using (var sr =
                       new StringReader(readtext.text))
            {
                // スタートの番号
                int usestartnum = int.MaxValue;

                for (int y = 0; y < chip_y; y++)
                {
                    string line = sr.ReadLine();
                    for (int x = 0; x < chip_x; x++)
                    {
                        loadrootnums[y][x] = mapchip.stringToInt(line, x);
                        if (loadrootnums[y][x] != -1)
                        {
                            if (usestartnum > loadrootnums[y][x])
                            {
                                usestartnum = loadrootnums[y][x];
                            }
                        }
                    }
                }

                List <List <RootType> > temproot_xy = new List <List <RootType> >();
                for (int y = 0; y < chip_y; y++)
                {
                    List <RootType> temploot_x = new List <RootType>();
                    for (int x = 0; x < chip_x; x++)
                    {
                        RootType tempnum = RootType.NONE;
                        if (loadrootnums[y][x] != -1)
                        {
                            if (usestartnum == loadrootnums[y][x])
                            {
                                tempnum = RootType.START;
                            }
                            else
                            {
                                tempnum = RootType.ROOT;
                            }
                        }

                        temploot_x.Add(tempnum);
                    }
                    temproot_xy.Add(temploot_x);
                }
                roots.Add(temproot_xy);

                sr.Close();
            }
            rootmax++;
        }
    }
        public void TestRoot()
        {
            var services = new ServiceCollection();

            services.TryAddJsonServices();
            services.TryAddJsonTypeConverter <IRootSnapshot, RootSnapshot>();
            services.TryAddJsonTypeConverter <IBranchSnapshot, BranchSnapshot>();
            services.TryAddJsonTypeConverter <ITreeSnapshot, TreeSnapshot>();

            var jsonService = services.BuildServiceProvider().GetService <IJsonService>();

            var root = RootType.Create(new RootSnapshot
            {
                Tree = new TreeSnapshot
                {
                    Branches = new IBranchSnapshot []
                    {
                        new BranchSnapshot {
                            Name = "branch 1"
                        },

                        new BranchSnapshot {
                            Name = "branch 2"
                        }
                    }
                }
            });

            Assert.NotNull(root);

            Assert.NotNull(root.Tree);

            Assert.Equal(2, root.Tree.Branches.Count);

            Assert.Equal("branch 1", root.Tree.Branches[0].Name);

            Assert.Equal("branch 2", root.Tree.Branches[1].Name);

            root.Tree.AddBranch(new BranchSnapshot {
                Name = "branch 4 (typo)"
            });

            Assert.Equal(3, root.Tree.Branches.Count);

            Assert.Equal("branch 4 (typo)", root.Tree.Branches[2].Name);

            root.Tree.Branches[2].EditName("branch 3");

            Assert.Equal("branch 3", root.Tree.Branches[2].Name);

            var rootSnapshot = new RootSnapshot
            {
                Tree = new TreeSnapshot
                {
                    Branches = new IBranchSnapshot[]
                    {
                        new BranchSnapshot {
                            Name = "snap branch 1"
                        },

                        new BranchSnapshot {
                            Name = "snap branch 2"
                        }
                    }
                }
            };

            root.ApplySnapshot(rootSnapshot);

            Assert.Equal(2, root.Tree.Branches.Count);

            Assert.Equal("snap branch 1", root.Tree.Branches[0].Name);

            Assert.Equal("snap branch 2", root.Tree.Branches[1].Name);

            var jsonSnapshot = jsonService.Serialize(rootSnapshot);

            var jsonSerialized = jsonService.Deserialize <RootSnapshot>(jsonSnapshot);

            root.ApplySnapshot(jsonSerialized);

            Assert.Equal(2, root.Tree.Branches.Count);

            Assert.Equal("snap branch 1", root.Tree.Branches[0].Name);

            Assert.Equal("snap branch 2", root.Tree.Branches[1].Name);
        }
Example #29
0
        private void OnSimulationCommencing(object sender, EventArgs e)
        {
            //zero public properties
            CumulativeFrondNumber = 0;
            CumulativeBunchNumber = 0;
            CarbonStress = 0;
            HarvestBunches = 0;
            HarvestFFB = 0;
            HarvestNRemoved = 0;
            HarvestBunchSize = 0;
            Age = 0;
            Population = 0;
            UnderstoryNFixation = 0;
            UnderstoryDltDM = 0;
            UnderstoryEP = 0;
            UnderstoryPEP = 0;
            UnderstoryFW = 0;
            StemMass = 0;
            StemN = 0;
            CropInGround = false;
            NUptake = new double[] { 0 };
            UnderstoryNUptake = new double[] { 0 };
            UnderstoryCoverGreen = 0;
            StemGrowth = 0;
            RootGrowth = 0;
            FrondGrowth = 0;
            BunchGrowth = 0;
            Fn = 1;
            FW = 1;
            Fvpd = 1;
            PEP = 0;
            EP = 0;
            RootDepth = 0;
            DltDM = 0;
            ReproductiveGrowthFraction = 0;

            Fronds = new List<FrondType>();
            Bunches = new List<BunchType>();
            Roots = new List<RootType>();

            soilCrop = Soil.Crop(Name) as SoilCropOilPalm;

            //MyPaddock.Parent.ChildPaddocks
            PotSWUptake = new double[Soil.Thickness.Length];
            SWUptake = new double[Soil.Thickness.Length];
            PotNUptake = new double[Soil.Thickness.Length];
            NUptake = new double[Soil.Thickness.Length];

            UnderstoryPotSWUptake = new double[Soil.Thickness.Length];
            UnderstorySWUptake = new double[Soil.Thickness.Length];
            UnderstoryPotNUptake = new double[Soil.Thickness.Length];
            UnderstoryNUptake = new double[Soil.Thickness.Length];

            for (int i = 0; i < Soil.Thickness.Length; i++)
            {
                RootType R = new RootType();
                Roots.Add(R);
                Roots[i].Mass = 0.1;
                Roots[i].N = Roots[i].Mass * RootNConcentration.Value / 100;
            }

            double FMA = FrondMaxArea.Value;
            double GrowthDuration = ExpandingFronds.Value * FrondAppearanceRate.Value;

            for (int i = 0; i < (int)InitialFrondNumber.Value; i++)
            {
                FrondType F = new FrondType();
                F.Age = ((int)InitialFrondNumber.Value - i) * FrondAppearanceRate.Value;
                F.Area = SizeFunction(F.Age, FMA, GrowthDuration);
                F.Mass = F.Area / SpecificLeafArea.Value;
                F.N = F.Mass * FrondCriticalNConcentration.Value / 100.0;
                Fronds.Add(F);
                CumulativeFrondNumber += 1;
            }
            for (int i = 0; i < (int)InitialFrondNumber.Value + 60; i++)
            {
                BunchType B = new BunchType();
                if (i>40)
                   B.FemaleFraction =  FemaleFlowerFraction.Value;
                else
                    B.FemaleFraction = 0;

                Bunches.Add(B);
            }
            RootDepth = InitialRootDepth;
        }
Example #30
0
 public TestTransactionReporter()
 {
     RootType.Define(new ExtensionInfo <TransactionReporter>());
     RootType.Define(new ExtensionInfo <TransactionContext>());
 }
Example #31
0
 public NestedType(RootType rootType)
 {
     RootType = rootType;
 }
Example #32
0
 public Info(RootType typ)
 {
     _Type = typ;
 }
Example #33
0
 public Info(RootType typ)
 {
     _Type = typ;
 }