Exemplo n.º 1
0
        public SimpleGuiCanvasPanel(SplitterPanel splitterPanel)
            : base(splitterPanel)
        {
            // set thisForm's properties and event handlers
            thisForm = this.Parent.ParentForm as SimpleGuiForm;
            thisForm.KeyPreview = true;

            thisForm.KeyDown += thisForm_KeyDown;
            thisForm.KeyUp += thisForm_KeyUp;
            thisForm.Deactivate += thisForm_Deactivate;
            thisForm.Activated += thisForm_Activated;
            thisForm.FormClosing += (o, e) => this.Stop();

            // set panel properties and event handlers
            Panel.BackColor = Color.White;
            Panel.GetType().GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic)
                           .SetValue(Panel, true, null);    // make panel double buffered to remove flicker

            Panel.MouseClick += splitterPanel_MouseClick;
            Panel.MouseMove += splitterPanel_MouseMove;
            Panel.Paint += Panel_Paint;

            // set the canvas and frame rate
            canvas = new Canvas() {
                BackgroundColor = Color.Black,
                Owner = splitterPanel,
                Size = new Size(480, 360),
            };

            this.TargetFrameRate = 30;

            downKeys = new System.Collections.Generic.HashSet<Keys>();
        }
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            System.IO.StreamReader reader = OpenInput(args);
            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine();
                if (line == null)
                    continue;

                string[] elements = line.Split(',');
                int[] intElements = System.Array.ConvertAll(elements, System.Int32.Parse);

                System.Collections.Generic.HashSet<int> set = new System.Collections.Generic.HashSet<int>();

                foreach (int element in intElements)
                {
                    if (!set.Contains(element))
                        set.Add(element);
                }

                int[] uniqueElements = new int[set.Count];
                set.CopyTo(uniqueElements);

                System.Array.Sort(uniqueElements);

                System.Console.WriteLine(string.Join(",", uniqueElements));
            }
        }
Exemplo n.º 3
0
		public FileSwitchDirectory(System.Collections.Generic.HashSet<string> primaryExtensions,
                                    Directory primaryDir, 
                                    Directory secondaryDir, 
                                    bool doClose)
		{
			this.primaryExtensions = primaryExtensions;
			this.primaryDir = primaryDir;
			this.secondaryDir = secondaryDir;
			this.doClose = doClose;
			this.interalLockFactory = primaryDir.LockFactory;
		}
        private void DeleteItems(MyGuiControlButton sender)
        {
            var treeType = MyObjectBuilderType.Parse("MyObjectBuilder_Trees");
            var items = new System.Collections.Generic.HashSet<MyEntity>();

            foreach (var entity in Sandbox.Game.Entities.MyEntities.GetEntities())
            {
                if (entity.GetObjectBuilder().TypeId == treeType)
                {
                    items.Add(entity);
                }
            }

            foreach (var item in items)
            {
                item.Close();
            }
        }
Exemplo n.º 5
0
 //Returns a new SearchTree and populates data param with the data used
 public SearchTree buildTreeAndData(int[] data)
 {
     Assert.That(data.Length == DataSize);
     var tree = new SearchTree();
     var added = new System.Collections.Generic.HashSet<int>();
     int data_index = 0;
     while(added.Count < DataSize){
         var val = random.Next(DataSize);
         if(added.Add(val)){
             data[data_index] = val;
             data_index++;
         }
     }
     InParallel(data, (int item) => {
         Assert.That(tree.Insert(item), "Couldn't insert unique item " + item);
         Assert.IsFalse(tree.Insert(item), "Inserted same item twice. item = " + item);
     });
     return tree;
 }
Exemplo n.º 6
0
        public static void Main(string[] args)
        {
            const int threads = 4;
            const int per_thread = 1000000;
            const int DataSize = threads * per_thread;
            SearchTree mySearchTree = new SearchTree();
            var random = new Random();
            var added = new int[DataSize];
            Console.Out.WriteLine("Inserting into tree");
            var stopWatch = new Stopwatch();
            stopWatch.Start();
            Parallel.For(0, threads, (int thread) => {
                for(int i = 0; i < per_thread; i++){
                    mySearchTree.Insert(added[thread * per_thread + i] = random.Next(DataSize));
                }
            });
            stopWatch.Stop();
            var ts = stopWatch.Elapsed;
            string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);
            Console.Out.WriteLine(DataSize + " insertions completed in " + elapsedTime + " on " + threads + " threads");

            Debug.Assert(!mySearchTree.Contains(-1), "Tree had -1, which was not inserted");

            foreach(var item in added){
                Debug.Assert(mySearchTree.Contains(item), "Tree couldn't find " + item);
            }

            //remove ~ 1/2 of the nodes, check for validity
            var removed = new System.Collections.Generic.HashSet<int>();
            for(var index = 0; index < DataSize; index+=2){
                var val = added[index];
                if(!removed.Contains(val)){
                    removed.Add(val);
                    Debug.Assert(mySearchTree.Remove(val), "Couldn't remove " + val);
                    Debug.Assert(!mySearchTree.Contains(val), "Found " + val + " after removal");
                }
            }
            Console.Out.WriteLine("Test completed successfully");
        }
Exemplo n.º 7
0
        static bool IsHappy(int inputNumber)
        {
            System.Collections.Generic.HashSet<int> numbersSeen = new System.Collections.Generic.HashSet<int>();
            while (!numbersSeen.Contains(inputNumber))
            {
                string inputString = inputNumber.ToString();
                numbersSeen.Add(inputNumber);

                inputNumber = 0;
                foreach (char digit in inputString)
                {
                    int digitVal = digit - '0';
                    inputNumber += digitVal * digitVal;
                }

                if (inputNumber == 1)
                {
                    return true;
                }
            }

            return false;
        }
        private static void Invert(IVisio.Window window)
        {
            if (window == null)
            {
                throw new System.ArgumentNullException("window");
            }

            if (window.Page == null)
            {
                throw new System.ArgumentException("Window has null page", "window");
            }

            var page = (IVisio.Page) window.Page;
            var shapes = page.Shapes;
            var all_shapes = shapes.AsEnumerable();
            var selection = window.Selection;
            var selected_set = new System.Collections.Generic.HashSet<IVisio.Shape>(selection.AsEnumerable());
            var shapes_to_select = all_shapes.Where(shape => !selected_set.Contains(shape)).ToList();

            window.DeselectAll();
            window.Select(shapes_to_select, IVisio.VisSelectArgs.visSelect);
        }
 protected internal override void PackToCore(MsgPack.Packer packer, System.Collections.Generic.HashSet <MsgPack.MessagePackObject[]> objectTree)
 {
     packer.PackArrayHeader(objectTree.Count);
     System.Collections.Generic.HashSet <MsgPack.MessagePackObject[]> .Enumerator enumerator = objectTree.GetEnumerator();
     MsgPack.MessagePackObject[] current;
     try {
         for (
             ; enumerator.MoveNext();
             )
         {
             current = enumerator.Current;
             this._serializer0.PackTo(packer, current);
         }
     }
     finally {
         enumerator.Dispose();
     }
 }
 internal static System.Collections.Generic.IDictionary <string, V> FromJson <V>(JsonObject json, System.Collections.Generic.Dictionary <string, V> container, System.Func <JsonObject, V> objectFactory, System.Collections.Generic.HashSet <string> excludes = null) => FromJson(json, (System.Collections.Generic.IDictionary <string, V>)container, objectFactory, excludes);
Exemplo n.º 11
0
 protected override System.Collections.Generic.HashSet <System.DateTime[]> CreateInstance(int initialCapacity)
 {
     System.Collections.Generic.HashSet <System.DateTime[]> collection = default(System.Collections.Generic.HashSet <System.DateTime[]>);
     collection = new System.Collections.Generic.HashSet <System.DateTime[]>(MsgPack.Serialization.UnpackHelpers.GetEqualityComparer <System.DateTime[]>());
     return(collection);
 }
Exemplo n.º 12
0
        static void WriteBackInstance(ILRuntime.Runtime.Enviorment.AppDomain __domain, StackObject *ptr_of_this_method, IList <object> __mStack, ref System.Collections.Generic.HashSet <ET.AService> .Enumerator instance_of_this_method)
        {
            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
            switch (ptr_of_this_method->ObjectType)
            {
            case ObjectTypes.Object:
            {
                __mStack[ptr_of_this_method->Value] = instance_of_this_method;
            }
            break;

            case ObjectTypes.FieldReference:
            {
                var ___obj = __mStack[ptr_of_this_method->Value];
                if (___obj is ILTypeInstance)
                {
                    ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = instance_of_this_method;
                }
                else
                {
                    var t = __domain.GetType(___obj.GetType()) as CLRType;
                    t.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, instance_of_this_method);
                }
            }
            break;

            case ObjectTypes.StaticFieldReference:
            {
                var t = __domain.GetType(ptr_of_this_method->Value);
                if (t is ILType)
                {
                    ((ILType)t).StaticInstance[ptr_of_this_method->ValueLow] = instance_of_this_method;
                }
                else
                {
                    ((CLRType)t).SetStaticFieldValue(ptr_of_this_method->ValueLow, instance_of_this_method);
                }
            }
            break;

            case ObjectTypes.ArrayReference:
            {
                var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as System.Collections.Generic.HashSet <ET.AService> .Enumerator[];
                instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method;
            }
            break;
            }
        }
Exemplo n.º 13
0
 public virtual void reset()
 {
     _firstName = null;
     _secondName = null;
     _seen = null;
 }
Exemplo n.º 14
0
 // Use this for initialization
 void Start()
 {
     if (allEnemies == null)
         allEnemies = new System.Collections.Generic.HashSet<EnemyMove> ();
     allEnemies.Add (this);
     combatant = GetComponent<Combatant> ();
     anim = GetComponent<Animator> ();
 }
Exemplo n.º 15
0
    public static void Update(bool forceUpdate = false)
    {
        //Gather all GeneratedSoundBanks folder from the project
        var allPaths     = AkUtilities.GetAllBankPaths();
        var bNeedRefresh = false;
        var projectPath  = System.IO.Path.GetDirectoryName(AkUtilities.GetFullPath(UnityEngine.Application.dataPath,
                                                                                   WwiseSettings.LoadSettings().WwiseProjectPath));

        AkWwiseInitializationSettings.UpdatePlatforms();

        //Go through all BasePlatforms
        foreach (var pairPF in AkUtilities.PlatformMapping)
        {
            //Go through all custom platforms related to that base platform and check if any of the bank files were updated.
            var bParse    = forceUpdate;
            var fullPaths = new System.Collections.Generic.List <string>();
            foreach (var customPF in pairPF.Value)
            {
                string bankPath;
                if (!allPaths.TryGetValue(customPF, out bankPath))
                {
                    continue;
                }

                var pluginFile = "";
                try
                {
                    pluginFile = System.IO.Path.Combine(projectPath, System.IO.Path.Combine(bankPath, "PluginInfo.xml"));
                    pluginFile = pluginFile.Replace('/', System.IO.Path.DirectorySeparatorChar);
                    if (!System.IO.File.Exists(pluginFile))
                    {
                        //Try in StreamingAssets too.
                        pluginFile = System.IO.Path.Combine(System.IO.Path.Combine(AkBasePathGetter.GetFullSoundBankPath(), customPF),
                                                            "PluginInfo.xml");
                        if (!System.IO.File.Exists(pluginFile))
                        {
                            continue;
                        }
                    }

                    fullPaths.Add(pluginFile);

                    var t        = System.IO.File.GetLastWriteTime(pluginFile);
                    var lastTime = System.DateTime.MinValue;
                    s_LastParsed.TryGetValue(customPF, out lastTime);
                    if (lastTime < t)
                    {
                        bParse = true;
                        s_LastParsed[customPF] = t;
                    }
                }
                catch (System.Exception ex)
                {
                    UnityEngine.Debug.LogError("WwiseUnity: " + pluginFile + " could not be parsed. " + ex.Message);
                }
            }

            if (bParse)
            {
                var platform = pairPF.Key;

                var newDlls = ParsePluginsXML(platform, fullPaths);
                System.Collections.Generic.HashSet <AkPluginInfo> oldDlls = null;

                //Remap base Wwise platforms to Unity platform folders names
#if !UNITY_2018_3_OR_NEWER
                if (platform.Contains("Vita"))
                {
                    platform = "Vita";
                }
#endif
                //else other platforms already have the right name

                s_PerPlatformPlugins.TryGetValue(platform, out oldDlls);
                s_PerPlatformPlugins[platform] = newDlls;

                //Check if there was any change.
                if (!bNeedRefresh && oldDlls != null)
                {
                    if (oldDlls.Count == newDlls.Count)
                    {
                        oldDlls.IntersectWith(newDlls);
                    }

                    bNeedRefresh |= oldDlls.Count != newDlls.Count;
                }
                else
                {
                    bNeedRefresh |= newDlls.Count > 0;
                }
            }
        }

        if (bNeedRefresh)
        {
            ActivatePluginsForEditor();
        }

        var currentConfig = GetCurrentConfig();
        CheckMenuItems(currentConfig);
    }
        public SingleInstanceLock(System.Collections.Generic.HashSet<string> locks, System.String lockName)
		{
			this.locks = locks;
			this.lockName = lockName;
		}
Exemplo n.º 17
0
 public FieldNameFilter(System.Collections.Generic.ICollection <string> acceptedFields)
 {
     this.acceptedFields = new System.Collections.Generic.HashSet <string>(acceptedFields);
 }
Exemplo n.º 18
0
 public FieldNameFilter(params string [] acceptedFields)
 {
     this.acceptedFields = new System.Collections.Generic.HashSet <string>(new System.Collections.Generic.List <string>(acceptedFields));
 }
Exemplo n.º 19
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public Master()
        {
            Children = new System.Collections.Generic.HashSet <Testing.Child>();

            Init();
        }
 public DefaultObjectQueryResultLazyList(Net.Vpc.Upa.Impl.Persistence.QueryExecutor queryExecutor, bool loadManyToOneRelations, bool defaultsToRecord, bool relationAsRecord, bool supportCache, bool updatable, Net.Vpc.Upa.Impl.Persistence.Result.QueryResultRelationLoader loader, Net.Vpc.Upa.Impl.Persistence.Result.QueryResultItemBuilder resultBuilder)  : base(queryExecutor)
 {
     this.resultBuilder          = resultBuilder;
     this.loader                 = loader;
     this.defaultsToRecord       = defaultsToRecord;
     this.relationAsRecord       = relationAsRecord;
     this.loadManyToOneRelations = loadManyToOneRelations;
     metaData = queryExecutor.GetMetaData();
     hints    = queryExecutor.GetHints();
     if (hints == null)
     {
         hints = new System.Collections.Generic.Dictionary <string, object>();
     }
     else
     {
         hints = new System.Collections.Generic.Dictionary <string, object>(hints);
     }
     if (supportCache)
     {
         Net.Vpc.Upa.Impl.Util.CacheMap <Net.Vpc.Upa.NamedId, object> sharedCache = (Net.Vpc.Upa.Impl.Util.CacheMap <Net.Vpc.Upa.NamedId, object>)Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, object>(hints, "queryCache");
         if (sharedCache == null)
         {
             sharedCache         = new Net.Vpc.Upa.Impl.Util.CacheMap <Net.Vpc.Upa.NamedId, object>(1000);
             hints["queryCache"] = sharedCache;
         }
         referencesCache = sharedCache;
     }
     loaderContext = new Net.Vpc.Upa.Impl.Persistence.Result.LoaderContext(referencesCache, hints);
     System.Collections.Generic.Dictionary <string, Net.Vpc.Upa.Impl.Persistence.Result.TypeInfo> bindingToTypeInfos0 = new System.Collections.Generic.Dictionary <string, Net.Vpc.Upa.Impl.Persistence.Result.TypeInfo>();
     ofactory = Net.Vpc.Upa.UPA.GetPersistenceUnit().GetFactory();
     Net.Vpc.Upa.Impl.Persistence.NativeField[] fields = queryExecutor.GetFields();
     for (int i = 0; i < fields.Length; i++)
     {
         Net.Vpc.Upa.Impl.Persistence.NativeField      nativeField = fields[i];
         Net.Vpc.Upa.Impl.Persistence.Result.FieldInfo f           = new Net.Vpc.Upa.Impl.Persistence.Result.FieldInfo();
         f.dbIndex     = i;
         f.nativeField = nativeField;
         f.name        = nativeField.GetName();
         string gn = nativeField.GetGroupName();
         if (gn == null)
         {
             gn = nativeField.GetExprString();
         }
         Net.Vpc.Upa.Impl.Persistence.Result.TypeInfo t = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, Net.Vpc.Upa.Impl.Persistence.Result.TypeInfo>(bindingToTypeInfos0, gn);
         if (t == null)
         {
             if (nativeField.GetField() != null)
             {
                 t        = new Net.Vpc.Upa.Impl.Persistence.Result.TypeInfo(gn, nativeField.GetField().GetEntity());
                 t.record = gn.Contains(".") ? relationAsRecord : defaultsToRecord;
                 bindingToTypeInfos0[gn] = t;
             }
             else
             {
                 t        = new Net.Vpc.Upa.Impl.Persistence.Result.TypeInfo(gn, null);
                 t.record = false;
                 //n.contains(".") ? relationAsRecord : defaultsToRecord;
                 bindingToTypeInfos0[gn] = t;
             }
         }
         //                if(!bindingToTypeInfos0.containsKey(nativeField.getExprString())) {
         //                    bindingToTypeInfos0.put(nativeField.getExprString(), t);
         //                }else{
         //                    System.out.println("why");
         //                }
         f.field = nativeField.GetField();
         if (loadManyToOneRelations)
         {
             if (f.field != null)
             {
                 if (f.field.GetDataType() is Net.Vpc.Upa.Types.ManyToOneType)
                 {
                     Net.Vpc.Upa.Entity r = ((Net.Vpc.Upa.Types.ManyToOneType)f.field.GetDataType()).GetTargetEntity();
                     f.referencedEntity = r;
                 }
                 foreach (Net.Vpc.Upa.Relationship relationship in f.field.GetManyToOneRelationships())
                 {
                     if (relationship.GetSourceRole().GetEntityField() != null)
                     {
                         t.manyToOneRelations.Add(relationship);
                     }
                 }
             }
         }
         f.typeInfo = t;
         t.allFields.Add(f);
         if (t.leadPrimaryField == null && f.nativeField.GetField() != null && f.nativeField.GetField().IsId())
         {
             t.leadPrimaryField = f;
         }
         if (t.leadField == null)
         {
             t.leadField = f;
         }
         f.setterMethodName           = Net.Vpc.Upa.Impl.Util.PlatformUtils.SetterName(nativeField.GetName());
         t.fields[f.setterMethodName] = f;
     }
     bindingToTypeInfos = bindingToTypeInfos0;
     typeInfos          = (bindingToTypeInfos0).Values.ToArray();
     // all indexes to fill with values from the query
     System.Collections.Generic.ISet <int?> allIndexes = new System.Collections.Generic.HashSet <int?>();
     for (int i = 0; i < (metaData.GetFields()).Count; i++)
     {
         allIndexes.Add(i);
     }
     // map expression to relative TypeInfo/FieldInfo
     System.Collections.Generic.IDictionary <string, object> visitedIndexes = new System.Collections.Generic.Dictionary <string, object>();
     for (int i = 0; i < typeInfos.Length; i++)
     {
         Net.Vpc.Upa.Impl.Persistence.Result.TypeInfo typeInfo = typeInfos[i];
         //            if (aliasName.equals(typeInfo.binding)) {
         //                entityIndex = i;
         //            }
         typeInfo.infosArray = typeInfo.allFields.ToArray();
         typeInfo.update     = false;
         foreach (Net.Vpc.Upa.Impl.Persistence.Result.FieldInfo field in typeInfo.infosArray)
         {
             if (!field.nativeField.IsExpanded() && field.nativeField.GetIndex() >= 0)
             {
                 field.update = true;
                 field.indexesToUpdate.Add(field.nativeField.GetIndex());
                 allIndexes.Remove(field.nativeField.GetIndex());
                 visitedIndexes[field.nativeField.GetExprString()] = field;
             }
         }
         if (typeInfo.entity == null)
         {
             typeInfo.update = true;
         }
         else
         {
             System.Collections.Generic.IList <Net.Vpc.Upa.Persistence.ResultField> fields1 = metaData.GetFields();
             for (int i1 = 0; i1 < (fields1).Count; i1++)
             {
                 Net.Vpc.Upa.Persistence.ResultField resultField = fields1[i1];
                 if (resultField.GetExpression().ToString().Equals(typeInfo.binding))
                 {
                     typeInfo.update = true;
                     typeInfo.indexesToUpdate.Add(i1);
                     allIndexes.Remove(i1);
                     visitedIndexes[typeInfo.binding] = typeInfo;
                     break;
                 }
             }
         }
     }
     //when an expression is to be expanded twice, implementation ignores second expansion
     // so we must find the equivalent expression index to handle
     foreach (int?remaining in allIndexes)
     {
         string k = metaData.GetFields()[(remaining).Value].GetExpression().ToString();
         object o = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, object>(visitedIndexes, k);
         if (o is Net.Vpc.Upa.Impl.Persistence.Result.TypeInfo)
         {
             ((Net.Vpc.Upa.Impl.Persistence.Result.TypeInfo)o).indexesToUpdate.Add(remaining);
         }
         else if (o is Net.Vpc.Upa.Impl.Persistence.Result.FieldInfo)
         {
             ((Net.Vpc.Upa.Impl.Persistence.Result.FieldInfo)o).indexesToUpdate.Add(remaining);
         }
         else
         {
             throw new Net.Vpc.Upa.Exceptions.UPAException("Unsupported");
         }
     }
     this.updatable = updatable;
 }
Exemplo n.º 21
0
 /// <exception cref="com.fasterxml.jackson.core.JsonParseException"/>
 public virtual bool isDup(string name)
 {
     if (_firstName == null)
     {
         _firstName = name;
         return false;
     }
     if (name.Equals(_firstName))
     {
         return true;
     }
     if (_secondName == null)
     {
         _secondName = name;
         return false;
     }
     if (name.Equals(_secondName))
     {
         return true;
     }
     if (_seen == null)
     {
         _seen = new System.Collections.Generic.HashSet<string>(16);
         // 16 is default, seems reasonable
         _seen.Add(_firstName);
         _seen.Add(_secondName);
     }
     return !_seen.Add(name);
 }
Exemplo n.º 22
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public Entity1()
        {
            Entity2 = new System.Collections.Generic.HashSet <global::MultiContext.Context1.Entity2>();

            Init();
        }
Exemplo n.º 23
0
 /// <summary>Expert: called when re-writing queries under MultiSearcher.
 /// 
 /// Create a single query suitable for use by all subsearchers (in 1-1
 /// correspondence with queries). This is an optimization of the OR of
 /// all queries. We handle the common optimization cases of equal
 /// queries and overlapping clauses of boolean OR queries (as generated
 /// by MultiTermQuery.rewrite()).
 /// Be careful overriding this method as queries[0] determines which
 /// method will be called and is not necessarily of the same type as
 /// the other queries.
 /// </summary>
 public virtual Query Combine(Query[] queries)
 {
     var uniques = new System.Collections.Generic.HashSet<Query>();
     for (int i = 0; i < queries.Length; i++)
     {
         Query query = queries[i];
         BooleanClause[] clauses = null;
         // check if we can split the query into clauses
         bool splittable = (query is BooleanQuery);
         if (splittable)
         {
             BooleanQuery bq = (BooleanQuery) query;
             splittable = bq.IsCoordDisabled();
             clauses = bq.GetClauses();
             for (int j = 0; splittable && j < clauses.Length; j++)
             {
                 splittable = (clauses[j].Occur == Occur.SHOULD);
             }
         }
         if (splittable)
         {
             for (int j = 0; j < clauses.Length; j++)
             {
                 uniques.Add(clauses[j].Query);
             }
         }
         else
         {
             uniques.Add(query);
         }
     }
     // optimization: if we have just one query, just return it
     if (uniques.Count == 1)
     {
         return uniques.First();
     }
     BooleanQuery result = new BooleanQuery(true);
     foreach (Query key in uniques)
     {
         result.Add(key, Occur.SHOULD);
     }
     return result;
 }
Exemplo n.º 24
0
        /// <summary>
        /// Default constructor. Protected due to required properties, but present because EF needs it.
        /// </summary>
        protected Master() : base()
        {
            Details = new System.Collections.Generic.HashSet <global::Sandbox_EF6.Detail>();

            Init();
        }
Exemplo n.º 25
0
    private static void SetupStaticPluginRegistration(UnityEditor.BuildTarget target)
    {
        if (!RequiresStaticPluginRegistration(target))
        {
            return;
        }

        string deploymentTargetName = GetPluginDeploymentPlatformName(target);

        var staticPluginRegistration = new StaticPluginRegistration(target);
        var importers = UnityEditor.PluginImporter.GetAllImporters();

        foreach (var pluginImporter in importers)
        {
            if (!pluginImporter.assetPath.Contains(WwisePluginFolder))
            {
                continue;
            }

            var splitPath = pluginImporter.assetPath.Split('/');

            // Path is Assets/Wwise/Deployment/Plugins/Platform. We need the platform string
            var pluginPlatform = splitPath[4];
            if (pluginPlatform != deploymentTargetName)
            {
                continue;
            }

            var pluginConfig = string.Empty;

            switch (pluginPlatform)
            {
            case "iOS":
            case "tvOS":
                pluginConfig = splitPath[5];
                break;

            case "Switch":
                if (SwitchBuildTarget == INVALID_BUILD_TARGET)
                {
                    continue;
                }

                pluginConfig = splitPath[6];

                var pluginArch = splitPath[5];
                if (pluginArch != "NX32" && pluginArch != "NX64")
                {
                    UnityEngine.Debug.Log("WwiseUnity: Architecture not found: " + pluginArch);
                    continue;
                }
                break;

            default:
                UnityEngine.Debug.Log("WwiseUnity: Unknown platform: " + pluginPlatform);
                continue;
            }

            if (pluginConfig != "DSP")
            {
                continue;
            }

            if (!IsPluginUsed(pluginPlatform, System.IO.Path.GetFileNameWithoutExtension(pluginImporter.assetPath)))
            {
                continue;
            }

            staticPluginRegistration.TryAddLibrary(pluginImporter.assetPath);
        }

        System.Collections.Generic.HashSet <AkPluginInfo> plugins = null;
        s_PerPlatformPlugins.TryGetValue(deploymentTargetName, out plugins);
        var missingPlugins = staticPluginRegistration.GetMissingPlugins(plugins);

        if (missingPlugins.Count == 0)
        {
            if (plugins == null)
            {
                UnityEngine.Debug.LogWarningFormat("WwiseUnity: The activated Wwise plug-ins may not be correct. Could not read PluginInfo.xml for platform: {0}", deploymentTargetName);
            }

            staticPluginRegistration.TryWriteToFile();
        }
        else
        {
            UnityEngine.Debug.LogErrorFormat(
                "WwiseUnity: These plugins used by the Wwise project are missing from the Unity project: {0}. Please check folder Assets/Wwise/Deployment/Plugin/{1}.",
                string.Join(", ", missingPlugins.ToArray()), deploymentTargetName);
        }
    }
Exemplo n.º 26
0
    static void Main(string[] args)
    {
        Debug.Assert(CCopasiRootContainer.getRoot() != null);
        // create a new datamodel
        CCopasiDataModel dataModel = CCopasiRootContainer.addDatamodel();
        Debug.Assert(CCopasiRootContainer.getDatamodelList().size() == 1);
        // first we load a simple model
          try
          {
              // load the model
              dataModel.importSBMLFromString(MODEL_STRING);
          }
          catch
          {
              System.Console.Error.WriteLine( "Error while importing the model.");
              System.Environment.Exit(1);
          }

        // now we need to run some time course simulation to get data to fit
        // against

        // get the trajectory task object
        CTrajectoryTask trajectoryTask = (CTrajectoryTask)dataModel.getTask("Time-Course");
        Debug.Assert(trajectoryTask != null);
        // if there isn't one
        if (trajectoryTask == null)
        {
            // create a new one
            trajectoryTask = new CTrajectoryTask();

            // add the new time course task to the task list
            // this method makes sure that the object is now owned
            // by the list and that it does not get deleted by SWIG
            dataModel.getTaskList().addAndOwn(trajectoryTask);
        }

        // run a deterministic time course
        trajectoryTask.setMethodType(CCopasiMethod.deterministic);

        // pass a pointer of the model to the problem
        trajectoryTask.getProblem().setModel(dataModel.getModel());

        // activate the task so that it will be run when the model is saved
        // and passed to CopasiSE
        trajectoryTask.setScheduled(true);

        // get the problem for the task to set some parameters
        CTrajectoryProblem problem = (CTrajectoryProblem)trajectoryTask.getProblem();

        // simulate 4000 steps
        problem.setStepNumber(4000);
        // start at time 0
        dataModel.getModel().setInitialTime(0.0);
        // simulate a duration of 400 time units
        problem.setDuration(400);
        // tell the problem to actually generate time series data
        problem.setTimeSeriesRequested(true);

        // set some parameters for the LSODA method through the method
        // Currently we don't use the method to set anything
        //CTrajectoryMethod method = (CTrajectoryMethod)trajectoryTask.getMethod();

        bool result=true;
        try
        {
            // now we run the actual trajectory
            result=trajectoryTask.processWithOutputFlags(true, (int)CCopasiTask.ONLY_TIME_SERIES);
        }
        catch
        {
            System.Console.Error.WriteLine( "Error. Running the time course simulation failed." );
            String lastErrors =  trajectoryTask.getProcessError();
          // check if there are additional error messages
          if (!string.IsNullOrEmpty(lastErrors))
          {
              // print the messages in chronological order
              System.Console.Error.WriteLine(lastErrors);
          }

            System.Environment.Exit(1);
        }
        if(result==false)
        {
            System.Console.Error.WriteLine( "An error occured while running the time course simulation.");
            String lastErrors =  trajectoryTask.getProcessError();
            // check if there are additional error messages
            if (!string.IsNullOrEmpty(lastErrors))
            {
                // print the messages in chronological order
                System.Console.Error.WriteLine(lastErrors);
            }
            System.Environment.Exit(1);
        }

        // we write the data to a file and add some noise to it
        // This is necessary since COPASI can only read experimental data from
        // file.
        CTimeSeries timeSeries = trajectoryTask.getTimeSeries();
        // we simulated 100 steps, including the initial state, this should be
        // 101 step in the timeseries
        Debug.Assert(timeSeries.getRecordedSteps() == 4001);
        uint i;
        uint iMax = (uint)timeSeries.getNumVariables();
        // there should be four variables, the three metabolites and time
        Debug.Assert(iMax == 5);
        uint lastIndex = (uint)timeSeries.getRecordedSteps() - 1;
        // open the file
        // we need to remember in which order the variables are written to file
        // since we need to specify this later in the parameter fitting task
        System.Collections.Generic.HashSet<uint> indexSet=new System.Collections.Generic.HashSet<uint>();
        System.Collections.Generic.List<CMetab> metabVector=new System.Collections.Generic.List<CMetab>();

        // write the header
        // the first variable in a time series is a always time, for the rest
        // of the variables, we use the SBML id in the header
        double random=0.0;
        System.Random rand_gen = new System.Random();
        try
        {
          System.IO.StreamWriter os = new System.IO.StreamWriter("fakedata_example6.txt");
          os.Write("# time ");
          CKeyFactory keyFactory=CCopasiRootContainer.getKeyFactory();
          Debug.Assert(keyFactory != null);
          for(i=1;i<iMax;++i)
          {
            string key=timeSeries.getKey(i);
            CCopasiObject obj=keyFactory.get(key);
            Debug.Assert(obj != null);
            // only write header data or metabolites
            System.Type type = obj.GetType();
            if(type.FullName.Equals("org.COPASI.CMetab"))
            {
              os.Write(", ");
              os.Write(timeSeries.getSBMLId(i,dataModel));
              CMetab m=(CMetab)obj;
              indexSet.Add(i);
              metabVector.Add(m);
            }
          }
          os.Write("\n");
          double data=0.0;
          for (i = 0;i < lastIndex;++i)
          {
            uint j;
            string s="";
            for(j=0;j<iMax;++j)
            {
              // we only want to  write the data for metabolites
              // the compartment does not interest us here
              if(j==0 || indexSet.Contains(j))
              {
                // write the data with some noise (+-5% max)
                random=rand_gen.NextDouble();
                data=timeSeries.getConcentrationData(i, j);
                // don't add noise to the time
                if(j!=0)
                {
                  data+=data*(random*0.1-0.05);
                }
                s=s+(System.Convert.ToString(data));
                s=s+", ";
              }
            }
            // remove the last two characters again
            os.Write(s.Substring(0,s.Length - 2));
            os.Write("\n");
          }
          os.Close();
        }
        catch (System.ApplicationException e)
        {
            System.Console.Error.WriteLine("Error. Could not write time course data to file.");
            System.Console.WriteLine(e.Message);
            System.Environment.Exit(1);
        }

        // now we change the parameter values to see if the parameter fitting
        // can really find the original values
        random=rand_gen.NextDouble()*10;
        CReaction reaction=dataModel.getModel().getReaction(0);
        // we know that it is an irreversible mass action, so there is one
        // parameter
        Debug.Assert(reaction.getParameters().size() == 1);
        Debug.Assert(reaction.isLocalParameter(0));
        // the parameter of a irreversible mass action is called k1
        reaction.setParameterValue("k1",random);

        reaction=dataModel.getModel().getReaction(1);
        // we know that it is an irreversible mass action, so there is one
        // parameter
        Debug.Assert(reaction.getParameters().size() == 1);
        Debug.Assert(reaction.isLocalParameter(0));
        reaction.setParameterValue("k1",random);

        CFitTask fitTask=(CFitTask)dataModel.addTask(CCopasiTask.parameterFitting);
        Debug.Assert(fitTask != null);
        // the method in a fit task is an instance of COptMethod or a subclass of
        // it.
        COptMethod fitMethod=(COptMethod)fitTask.getMethod();
        Debug.Assert(fitMethod != null);
        // the object must be an instance of COptMethod or a subclass thereof
        // (CFitMethod)
        CFitProblem fitProblem=(CFitProblem)fitTask.getProblem();
        Debug.Assert(fitProblem != null);

        CExperimentSet experimentSet=(CExperimentSet)fitProblem.getParameter("Experiment Set");
        Debug.Assert(experimentSet != null);

        // first experiment (we only have one here)
        CExperiment experiment=new CExperiment(dataModel);
        Debug.Assert(experiment != null);
        // tell COPASI where to find the data
        // reading data from string is not possible with the current C++ API
        experiment.setFileName("fakedata_example6.txt");
        // we have to tell COPASI that the data for the experiment is a komma
        // separated list (the default is TAB separated)
        experiment.setSeparator(",");
        // the data start in row 1 and goes to row 4001
        experiment.setFirstRow(1);
        Debug.Assert(experiment.getFirstRow()==1);
        experiment.setLastRow(4001);
        Debug.Assert(experiment.getLastRow()==4001);
        experiment.setHeaderRow(1);
        Debug.Assert(experiment.getHeaderRow()==1);
        experiment.setExperimentType(CCopasiTask.timeCourse);
        Debug.Assert(experiment.getExperimentType()==CCopasiTask.timeCourse);
        experiment.setNumColumns(4);
        Debug.Assert(experiment.getNumColumns()==4);
        CExperimentObjectMap objectMap=experiment.getObjectMap();
        Debug.Assert(objectMap != null);
        result=objectMap.setNumCols(4);
        Debug.Assert(result == true);
        result=objectMap.setRole(0,CExperiment.time);
        Debug.Assert(result == true);
        Debug.Assert(objectMap.getRole(0) == CExperiment.time);

        CModel model=dataModel.getModel();
        Debug.Assert(model!=null);
        CCopasiObject timeReference=model.getValueReference();
        Debug.Assert(timeReference != null);
        objectMap.setObjectCN(0,timeReference.getCN().getString());

        // now we tell COPASI which column contain the concentrations of
        // metabolites and belong to dependent variables
        objectMap.setRole(1,CExperiment.dependent);
        CMetab metab=metabVector[0];
        Debug.Assert(metab != null);
        CCopasiObject particleReference=metab.getConcentrationReference();
        Debug.Assert(particleReference != null);
        objectMap.setObjectCN(1,particleReference.getCN().getString());

        objectMap.setRole(2,CExperiment.dependent);
        metab=metabVector[1];
        Debug.Assert(metab != null);
        particleReference=metab.getConcentrationReference();
        Debug.Assert(particleReference != null);
        objectMap.setObjectCN(2,particleReference.getCN().getString());

        objectMap.setRole(3,CExperiment.dependent);
        metab=metabVector[2];
        Debug.Assert(metab != null);
        particleReference=metab.getConcentrationReference();
        Debug.Assert(particleReference != null);
        objectMap.setObjectCN(3,particleReference.getCN().getString());

        experimentSet.addExperiment(experiment);
        Debug.Assert(experimentSet.getExperimentCount()==1);
        // addExperiment makes a copy, so we need to get the added experiment
        // again
        experiment=experimentSet.getExperiment(0);
        Debug.Assert(experiment != null);

        // now we have to define the two fit items for the two local parameters
        // of the two reactions
        reaction=model.getReaction(0);
        Debug.Assert(reaction != null);
        Debug.Assert(reaction.isLocalParameter(0)==true);
        CCopasiParameter parameter=reaction.getParameters().getParameter(0);
        Debug.Assert(parameter != null);

        // define a CFitItem
        CCopasiObject parameterReference=parameter.getValueReference();
        Debug.Assert(parameterReference != null);
        CFitItem fitItem1=new CFitItem(dataModel);
        Debug.Assert(fitItem1 !=null);
        fitItem1.setObjectCN(parameterReference.getCN());
        fitItem1.setStartValue(4.0);
        fitItem1.setLowerBound(new CCopasiObjectName("0.00001"));
        fitItem1.setUpperBound(new CCopasiObjectName("10"));
        // add the fit item to the correct parameter group
        CCopasiParameterGroup optimizationItemGroup=(CCopasiParameterGroup)fitProblem.getParameter("OptimizationItemList");
        Debug.Assert(optimizationItemGroup != null);
        optimizationItemGroup.addParameter(fitItem1);

        reaction=model.getReaction(1);
        Debug.Assert(reaction != null);
        Debug.Assert(reaction.isLocalParameter(0)==true);
        parameter=reaction.getParameters().getParameter(0);
        Debug.Assert(parameter != null);

        // define a CFitItem
        parameterReference=parameter.getValueReference();
        Debug.Assert(parameterReference != null);
        CFitItem fitItem2=new CFitItem(dataModel);
        Debug.Assert(fitItem2 !=null);
        fitItem2.setObjectCN(parameterReference.getCN());
        fitItem2.setStartValue(4.0);
        fitItem2.setLowerBound(new CCopasiObjectName("0.00001"));
        fitItem2.setUpperBound(new CCopasiObjectName("10"));
        // add the fit item to the correct parameter group
        optimizationItemGroup.addParameter(fitItem2);

        result=true;
        try
        {
          // running the task for this example will probably take some time
          System.Console.WriteLine("This can take some time...");
          result=fitTask.processWithOutputFlags(true, (int)CCopasiTask.ONLY_TIME_SERIES);
        }
        catch
        {
          System.Console.Error.WriteLine("Error. Parameter fitting failed.");
          String lastErrors =  fitTask.getProcessError();
          // check if there are additional error messages
          if (!string.IsNullOrEmpty(lastErrors))
          {
              // print the messages in chronological order
              System.Console.Error.WriteLine(lastErrors);
          }

          System.Environment.Exit(1);
        }

        Debug.Assert(result == true);
        // assert that there are two optimization items
        Debug.Assert(fitProblem.getOptItemList().Count == 2);
        // the order should be the order in whih we added the items above
        COptItem optItem1 = fitProblem.getOptItemList()[0];
        COptItem optItem2 = fitProblem.getOptItemList()[1];
        // the actual results are stored in the fit problem
        Debug.Assert(fitProblem.getSolutionVariables().size() == 2);
        System.Console.WriteLine("value for " + optItem1.getObject().getCN().getString() + ": " + fitProblem.getSolutionVariables().get(0));
        System.Console.WriteLine("value for " + optItem2.getObject().getCN().getString() + ": " + fitProblem.getSolutionVariables().get(1));
        // depending on the noise, the fit can be quite bad, so we are a litle
        // relaxed here (we should be within 3% of the original values)
        Debug.Assert((System.Math.Abs(fitProblem.getSolutionVariables().get(0) - 0.03) / 0.03) < 3e-2);
        Debug.Assert((System.Math.Abs(fitProblem.getSolutionVariables().get(1) - 0.004) / 0.004) < 3e-2);
    }
Exemplo n.º 27
0
 /// <summary>
 /// Raises the level was loaded event.
 /// </summary>
 /// <param name="n">N.</param>
 void OnLevelWasLoaded(int n)
 {
     if (allEnemies != null)
         allEnemies = null;
 }
Exemplo n.º 28
0
 protected virtual void ValidateMandatorySwitches(Catel.Data.IValidationContext validationContext, System.Collections.Generic.IEnumerable <Orc.CommandLine.OptionDefinition> optionDefinitions, System.Collections.Generic.HashSet <string> handledOptions)
 {
 }
Exemplo n.º 29
0
    private static System.Collections.Generic.HashSet <AkPluginInfo> ParsePluginsXML(string platform,
                                                                                     System.Collections.Generic.List <string> in_pluginFiles)
    {
        var newPlugins = new System.Collections.Generic.HashSet <AkPluginInfo>();

        foreach (var pluginFile in in_pluginFiles)
        {
            if (!System.IO.File.Exists(pluginFile))
            {
                continue;
            }

            try
            {
                var doc = new System.Xml.XmlDocument();
                doc.Load(pluginFile);
                var Navigator      = doc.CreateNavigator();
                var pluginInfoNode = Navigator.SelectSingleNode("//PluginInfo");
                var boolMotion     = pluginInfoNode.GetAttribute("Motion", "");

                var it = Navigator.Select("//Plugin");

                if (boolMotion == "true")
                {
                    AkPluginInfo motionPluginInfo = new AkPluginInfo();
                    motionPluginInfo.DllName = "AkMotion";
                    newPlugins.Add(motionPluginInfo);
                }

                foreach (System.Xml.XPath.XPathNavigator node in it)
                {
                    var rawPluginID = uint.Parse(node.GetAttribute("ID", ""));
                    if (rawPluginID == 0)
                    {
                        continue;
                    }

                    PluginID pluginID = (PluginID)rawPluginID;

                    if (alwaysSkipPluginsIDs.Contains(pluginID))
                    {
                        continue;
                    }

                    var dll = string.Empty;

                    if (platform == "Switch")
                    {
                        if (pluginID == PluginID.AkMeter)
                        {
                            dll = "AkMeter";
                        }
                    }
                    else if (builtInPluginIDs.Contains(pluginID))
                    {
                        continue;
                    }

                    if (string.IsNullOrEmpty(dll))
                    {
                        dll = node.GetAttribute("DLL", "");
                    }

                    AkPluginInfo newPluginInfo = new AkPluginInfo();
                    newPluginInfo.PluginID = rawPluginID;
                    newPluginInfo.DllName  = dll;

                    if (PluginIDToStaticLibName.ContainsKey(pluginID))
                    {
                        newPluginInfo.StaticLibName = PluginIDToStaticLibName[pluginID];
                    }

                    newPlugins.Add(newPluginInfo);
                }
            }
            catch (System.Exception ex)
            {
                UnityEngine.Debug.LogError("WwiseUnity: " + pluginFile + " could not be parsed. " + ex.Message);
            }
        }

        return(newPlugins);
    }
Exemplo n.º 30
0
        /// <summary>
        /// Default constructor. Protected due to being abstract.
        /// </summary>
        protected EntityAbstract()
        {
            EntityRelated = new System.Collections.Generic.HashSet <global::Testing.EntityRelated>();

            Init();
        }
Exemplo n.º 31
0
 public System.Collections.Generic.IEnumerable <DbUp.Engine.SqlScript> Filter(System.Collections.Generic.IEnumerable <DbUp.Engine.SqlScript> sorted, System.Collections.Generic.HashSet <string> executedScriptNames, DbUp.Support.ScriptNameComparer comparer)
 {
 }
Exemplo n.º 32
0
        /// <summary>
        /// Default constructor. Protected due to required properties, but present because EF needs it.
        /// </summary>
        protected BParentOptional()
        {
            BChildCollection = new System.Collections.Generic.HashSet <global::Testing.BChild>();

            Init();
        }
Exemplo n.º 33
0
 public static void Equal <T>(System.Collections.Generic.HashSet <T> expected, System.Collections.Generic.HashSet <T> actual)
 {
 }
        static StackObject *Recycle_1(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Collections.Generic.HashSet <ILRuntime.Runtime.Intepreter.ILTypeInstance> @t = (System.Collections.Generic.HashSet <ILRuntime.Runtime.Intepreter.ILTypeInstance>) typeof(System.Collections.Generic.HashSet <ILRuntime.Runtime.Intepreter.ILTypeInstance>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            ETModel.Pool <System.Collections.Generic.HashSet <ILRuntime.Runtime.Intepreter.ILTypeInstance> > instance_of_this_method = (ETModel.Pool <System.Collections.Generic.HashSet <ILRuntime.Runtime.Intepreter.ILTypeInstance> >) typeof(ETModel.Pool <System.Collections.Generic.HashSet <ILRuntime.Runtime.Intepreter.ILTypeInstance> >).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.Recycle(@t);

            return(__ret);
        }
        /// <summary>
        /// Default constructor
        /// </summary>
        public UParentRequired()
        {
            UChildCollection = new System.Collections.Generic.HashSet <global::Testing.UChild>();

            Init();
        }
Exemplo n.º 36
0
 /// <summary>
 /// Return all distinct characters composing the input string.
 /// Even if present more than once in the input string, each character is only present once in the result array.
 /// A character not present in the input string won't be present in the result array.
 /// </summary>
 /// <param name="input">String to be analyzed</param>
 /// <returns>Distinct characters composing input.</returns>
 private static char[] distinct(string input)
 {
     System.Collections.Generic.HashSet<char> set = new System.Collections.Generic.HashSet<char>(input);
     char[] result = new char[set.Count];
     set.CopyTo(result);
     return result;
 }
Exemplo n.º 37
0
        public virtual void Visit(Net.Vpc.Upa.Config.Decoration d)
        {
            string typeName = d.GetLocationType();

            try {
                if (enableLog && typeName.ToLower().Contains("upalock"))
                {
                    log.TraceEvent(System.Diagnostics.TraceEventType.Error, 100, Net.Vpc.Upa.Impl.FwkConvertUtils.LogMessageExceptionFormatter("\t[{0}] unexpected registration of {1}", null, new object[] { name, typeName }));
                }
            } catch (System.Exception e) {
                System.Console.WriteLine(e);
            }
            string methodOrFieldName = d.GetLocation();

            Net.Vpc.Upa.Config.DecorationTarget targetType = d.GetTarget();
            if (enableLog && /*IsLoggable=*/ true)
            {
                log.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 40, Net.Vpc.Upa.Impl.FwkConvertUtils.LogMessageExceptionFormatter("\t[{0}] register Decoration {1}", null, new object[] { name, d }));
            }
            Net.Vpc.Upa.Impl.Config.Decorations.DefaultDecorationRepositoryTypeInfo typeInfo = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, Net.Vpc.Upa.Impl.Config.Decorations.DefaultDecorationRepositoryTypeInfo>(decorationsByType, typeName);
            if (typeInfo == null)
            {
                typeInfo                    = new Net.Vpc.Upa.Impl.Config.Decorations.DefaultDecorationRepositoryTypeInfo();
                typeInfo.typeName           = typeName;
                decorationsByType[typeName] = typeInfo;
            }
            if (targetType != default(Net.Vpc.Upa.Config.DecorationTarget))
            {
                switch (targetType)
                {
                case Net.Vpc.Upa.Config.DecorationTarget.TYPE:
                {
                    if (typeInfo.decorations == null)
                    {
                        typeInfo.decorations = new System.Collections.Generic.List <Net.Vpc.Upa.Config.Decoration>(3);
                    }
                    System.Collections.Generic.IList <Net.Vpc.Upa.Config.Decoration> m = typeInfo.decorations;
                    int found = -1;
                    for (int i = 0; i < (m).Count; i++)
                    {
                        Net.Vpc.Upa.Config.Decoration m1 = m[i];
                        if (m1.GetName().Equals(d.GetName()) && m1.GetPosition() == d.GetPosition())
                        {
                            found = i;
                            break;
                        }
                    }
                    if (found < 0)
                    {
                        m.Add(d);
                    }
                    break;
                }

                case Net.Vpc.Upa.Config.DecorationTarget.METHOD:
                {
                    if (typeInfo.methods == null)
                    {
                        typeInfo.methods = new System.Collections.Generic.Dictionary <string, System.Collections.Generic.IList <Net.Vpc.Upa.Config.Decoration> >();
                        System.Collections.Generic.IList <Net.Vpc.Upa.Config.Decoration> m = new System.Collections.Generic.List <Net.Vpc.Upa.Config.Decoration>();
                        typeInfo.methods[methodOrFieldName] = m;
                        m.Add(d);
                    }
                    else
                    {
                        System.Collections.Generic.IList <Net.Vpc.Upa.Config.Decoration> m = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, System.Collections.Generic.IList <Net.Vpc.Upa.Config.Decoration> >(typeInfo.methods, methodOrFieldName);
                        if (m == null)
                        {
                            m = new System.Collections.Generic.List <Net.Vpc.Upa.Config.Decoration>();
                            typeInfo.methods[methodOrFieldName] = m;
                        }
                        int found = -1;
                        for (int i = 0; i < (m).Count; i++)
                        {
                            Net.Vpc.Upa.Config.Decoration m1 = m[i];
                            if (m1.GetName().Equals(d.GetName()) && m1.GetPosition() == d.GetPosition())
                            {
                                found = i;
                                break;
                            }
                        }
                        if (found < 0)
                        {
                            m.Add(d);
                        }
                    }
                    break;
                }

                case Net.Vpc.Upa.Config.DecorationTarget.FIELD:
                {
                    if (typeInfo.fields == null)
                    {
                        typeInfo.fields = new System.Collections.Generic.Dictionary <string, System.Collections.Generic.IList <Net.Vpc.Upa.Config.Decoration> >();
                        System.Collections.Generic.IList <Net.Vpc.Upa.Config.Decoration> m = new System.Collections.Generic.List <Net.Vpc.Upa.Config.Decoration>();
                        typeInfo.fields[methodOrFieldName] = m;
                        m.Add(d);
                    }
                    else
                    {
                        System.Collections.Generic.IList <Net.Vpc.Upa.Config.Decoration> m = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, System.Collections.Generic.IList <Net.Vpc.Upa.Config.Decoration> >(typeInfo.fields, methodOrFieldName);
                        if (m == null)
                        {
                            m = new System.Collections.Generic.List <Net.Vpc.Upa.Config.Decoration>();
                            typeInfo.fields[methodOrFieldName] = m;
                        }
                        int found = -1;
                        for (int i = 0; i < (m).Count; i++)
                        {
                            Net.Vpc.Upa.Config.Decoration m1 = m[i];
                            if (m1.GetName().Equals(d.GetName()) && m1.GetPosition() == d.GetPosition())
                            {
                                found = i;
                                break;
                            }
                        }
                        if (found < 0)
                        {
                            m.Add(d);
                        }
                    }
                    break;
                }
                }
            }
            System.Collections.Generic.ISet <string> tt = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, System.Collections.Generic.ISet <string> >(typesByDecoration, d.GetName());
            if (tt == null)
            {
                tt = new System.Collections.Generic.HashSet <string>();
                typesByDecoration[d.GetName()] = tt;
            }
            tt.Add(typeName);
        }
Exemplo n.º 38
0
        /// <summary>
        /// Default constructor. Protected due to required properties, but present because EF needs it.
        /// </summary>
        protected Configuration1C()
        {
            ArticleDependencies = new System.Collections.Generic.HashSet <WebApi.EF.Models.ArticleDependencies>();

            Init();
        }
        internal static System.Collections.Generic.IDictionary <string, V> FromJson <V>(JsonObject json, System.Collections.Generic.IDictionary <string, V> container, System.Func <JsonObject, V> objectFactory, System.Collections.Generic.HashSet <string> excludes = null)
        {
            if (null == json)
            {
                return(container);
            }

            foreach (var key in json.Keys)
            {
                if (true == excludes?.Contains(key))
                {
                    continue;
                }

                var value = json[key];
                try
                {
                    switch (value.Type)
                    {
                    case JsonType.Null:
                        // skip null values.
                        continue;

                    case JsonType.Array:
                    case JsonType.Boolean:
                    case JsonType.Date:
                    case JsonType.Binary:
                    case JsonType.Number:
                    case JsonType.String:
                        container.Add(key, (V)value.ToValue());
                        break;

                    case JsonType.Object:
                        if (objectFactory != null)
                        {
                            var v = objectFactory(value as JsonObject);
                            if (null != v)
                            {
                                container.Add(key, v);
                            }
                        }
                        break;
                    }
                }
                catch
                {
                }
            }
            return(container);
        }
Exemplo n.º 40
0
        bool IsDataValid(System.Collections.Generic.IEnumerable<string> in_colNames, System.Collections.Generic.IEnumerable<string> in_rowNames)
        {
            var ret = true;
            var hashset = new System.Collections.Generic.HashSet<string>();

            foreach (var item in in_colNames)
            {
                if (hashset.Add(item))
                {
                    if (!ContainsKeyword(item)) continue;
                    Debug.LogError("Unsupported column name (" + item +
                                   ") please check you name is not a reserved word or keyword and change this value");
                    ret = false;
                    break;
                }

                Debug.LogError("Duplicate column name (" + item + ") please check your column names for duplicate names");
                ret = false;
                break;
            }

            // rowNames must be unique, valid enumerations
            if (!ret) return false;

            hashset.Clear();
            foreach (var item in in_rowNames)
            {
                if (hashset.Add(item))
                {
                    if (IsValidEnumerationName(item)) continue;
                    Debug.LogError("Unsupported row name (" + item +
                                   ") please check you name is not a reserved word or keyword and change this value");
                    ret = false;
                    break;
                }

                Debug.LogError("Duplicate row name (" + item + ") please check your row names for duplicate names");
                ret = false;
                break;
            }

            return ret;
        }
Exemplo n.º 41
0
    private static void UpdateAllClips()
    {
        var guids = UnityEditor.AssetDatabase.FindAssets("t:AkEventPlayable", new[] { "Assets" });

        if (guids.Length < 1)
        {
            return;
        }

        var processedGuids = new System.Collections.Generic.HashSet <string>();

        for (var i = 0; i < guids.Length; i++)
        {
            UpdateProgressBar(i, guids.Length);

            var guid = guids[i];
            if (processedGuids.Contains(guid))
            {
                continue;
            }

            processedGuids.Add(guid);

            var path        = UnityEditor.AssetDatabase.GUIDToAssetPath(guid);
            var objects     = UnityEditor.AssetDatabase.LoadAllAssetsAtPath(path);
            var instanceIds = new System.Collections.Generic.List <int>();
            foreach (var obj in objects)
            {
                if (obj == null)
                {
                    continue;
                }

                var id = obj.GetInstanceID();
                if (!instanceIds.Contains(id))
                {
                    instanceIds.Add(id);
                }
            }

            for (; instanceIds.Count > 0; instanceIds.RemoveAt(0))
            {
                var id = instanceIds[0];
                objects = UnityEditor.AssetDatabase.LoadAllAssetsAtPath(path);
                foreach (var obj in objects)
                {
                    if (obj && obj.GetInstanceID() == id)
                    {
                        var playable = obj as AkEventPlayable;
                        if (playable)
                        {
                            var serializedObject = new UnityEditor.SerializedObject(playable);
                            var setClipDuration  = serializedObject.FindProperty("UseWwiseEventDuration").boolValue;
                            UpdateClipInformation(playable.owningClip, playable.akEvent, serializedObject, setClipDuration);
                            serializedObject.ApplyModifiedProperties();
                        }

                        break;
                    }
                }
            }
        }

        UnityEditor.EditorUtility.ClearProgressBar();
    }
Exemplo n.º 42
0
        bool IsDataValid(System.Collections.Generic.IEnumerable<string> in_types, System.Collections.Generic.IEnumerable<string> in_colNames, System.Collections.Generic.IEnumerable<string> in_rowNames)
        {
            bool ret = true;
            var hashset = new System.Collections.Generic.HashSet<string>();
            // types must be a type we support
            foreach (var type in in_types.Where(in_type => !IsSupportedType(in_type)))
            {
                Debug.LogError("Unsupported type " + type + " please check your database column types and change this value to a supported type");
                ret = false;
                break;
            }

            // colNames cannot contain language keywords, and must also be unique
            if (ret)
            {
                foreach (var item in in_colNames.Where(in_item => !GfuStrCmp(in_item, "void")))
                {
                    if (hashset.Add(item))
                    {
                        if (!ContainsKeyword(item)) continue;
                        Debug.LogError("Unsupported column name (" + item +
                                       ") please check you name is not a reserved word or keyword and change this value");
                        ret = false;
                        break;
                    }

                    Debug.LogError("Duplicate column name (" + item + ") please check your column names for duplicate names");
                    ret = false;
                    break;
                }
            }

            // rowNames must be unique, valid enumerations
            if (!ret) return false;

            hashset.Clear();
            foreach (var item in in_rowNames.Where(in_item => !GfuStrCmp(in_item, "void")))
            {
                if (hashset.Add(item))
                {
                    if (IsValidEnumerationName(item)) continue;
                    Debug.LogError("Unsupported row name (" + item +
                                   ") please check you name is not a reserved word or keyword and change this value");
                    ret = false;
                    break;
                }

                Debug.LogError("Duplicate row name (" + item + ") please check your row names for duplicate names");
                ret = false;
                break;
            }

            return ret;
        }
Exemplo n.º 43
0
        /// <summary>
        /// Default constructor. Protected due to required properties, but present because EF needs it.
        /// </summary>
        protected UParentCollection()
        {
            UChildCollection = new System.Collections.Generic.HashSet <Testing.UChild>();

            Init();
        }
Exemplo n.º 44
0
    private static System.Collections.Generic.HashSet <string> ParsePluginsXML(string platform,
                                                                               System.Collections.Generic.List <string> in_pluginFiles)
    {
        var newDlls = new System.Collections.Generic.HashSet <string>();

        foreach (var pluginFile in in_pluginFiles)
        {
            if (!System.IO.File.Exists(pluginFile))
            {
                continue;
            }

            try
            {
                var doc = new System.Xml.XmlDocument();
                doc.Load(pluginFile);
                var Navigator      = doc.CreateNavigator();
                var pluginInfoNode = Navigator.SelectSingleNode("//PluginInfo");
                var boolMotion     = pluginInfoNode.GetAttribute("Motion", "");

                var it = Navigator.Select("//Plugin");

                if (boolMotion == "true")
                {
                    newDlls.Add("AkMotion");
                }

                foreach (System.Xml.XPath.XPathNavigator node in it)
                {
                    var pid = uint.Parse(node.GetAttribute("ID", ""));
                    if (pid == 0)
                    {
                        continue;
                    }

                    var dll = string.Empty;

                    if (platform == "Switch")
                    {
                        if ((PluginID)pid == PluginID.WwiseMeter)
                        {
                            dll = "AkMeter";
                        }
                    }
                    else if (builtInPluginIDs.Contains((PluginID)pid))
                    {
                        continue;
                    }

                    if (string.IsNullOrEmpty(dll))
                    {
                        dll = node.GetAttribute("DLL", "");
                    }

                    newDlls.Add(dll);
                }
            }
            catch (System.Exception ex)
            {
                UnityEngine.Debug.LogError("WwiseUnity: " + pluginFile + " could not be parsed. " + ex.Message);
            }
        }

        return(newDlls);
    }
Exemplo n.º 45
0
 public Reader(string feedPath)
 {
     this.asins = new System.Collections.Generic.HashSet<string>();
     this.reader = XmlReader.Create(feedPath);
 }
Exemplo n.º 46
0
        protected override async Task StartWithIGraph(IGraph graph, ILookup newContext)
        {
            OptionGroup layoutGroup      = Handler.GetGroupByName(GROUP_LAYOUT);
            string      busDetermination = (string)layoutGroup[BUSES].Value;

            ISelectionModel <IModelItem> selectionModel = newContext.Lookup <ISelectionModel <IModelItem> >();

            var mapperRegistry = graph.MapperRegistry;
            var originalBusIds = mapperRegistry.GetMapper(BusRouter.EdgeDescriptorDpKey);

            IMapper <IEdge, BusDescriptor> busIds;

            if (busDetermination != CUSTOM)
            {
                mapperRegistry.RemoveMapper(BusRouter.EdgeDescriptorDpKey);
                busIds = mapperRegistry.CreateMapper <IEdge, BusDescriptor>(BusRouter.EdgeDescriptorDpKey);

                var scopePartial = (string)layoutGroup[SCOPE].Value == PARTIAL;
                foreach (var edge in graph.Edges)
                {
                    bool isFixed = scopePartial &&
                                   !IsSelected(selectionModel, edge.GetSourceNode()) &&
                                   !IsSelected(selectionModel, edge.GetTargetNode());
                    busIds[edge] = new BusDescriptor(GetBusId(edge, busDetermination), isFixed);
                }
            }
            else
            {
                busIds = originalBusIds
                         ?? mapperRegistry.CreateConstantMapper(BusRouter.EdgeDescriptorDpKey, new BusDescriptor(SingleBusId));
            }


            var originalEdgeSubsetMapper = mapperRegistry.GetMapper(BusRouter.DefaultAffectedEdgesDpKey);

            if (originalEdgeSubsetMapper != null)
            {
                mapperRegistry.RemoveMapper(BusRouter.DefaultAffectedEdgesDpKey);
            }
            var selectedIds = new System.Collections.Generic.HashSet <object>();

            switch ((string)layoutGroup[SCOPE].Value)
            {
            case SUBSET:
                mapperRegistry.CreateDelegateMapper(BusRouter.DefaultAffectedEdgesDpKey, e => IsSelected(selectionModel, e));
                break;

            case SUBSET_BUS:
                foreach (var edge in graph.Edges.Where(edge => IsSelected(selectionModel, edge)))
                {
                    selectedIds.Add(busIds[edge].BusId);
                }
                mapperRegistry.CreateDelegateMapper(BusRouter.DefaultAffectedEdgesDpKey, e => selectedIds.Contains(busIds[e].BusId));
                break;

            case PARTIAL:
                foreach (var edge in graph.Nodes.Where(node => IsSelected(selectionModel, node)).SelectMany((node) => graph.EdgesAt(node)))
                {
                    selectedIds.Add(busIds[edge].BusId);
                }
                mapperRegistry.CreateDelegateMapper(BusRouter.DefaultAffectedEdgesDpKey, e => selectedIds.Contains(busIds[e].BusId));
                break;
            }

            try {
                await base.StartWithIGraph(graph, newContext);
            } finally {
                mapperRegistry.RemoveMapper(BusRouter.EdgeDescriptorDpKey);
                if (originalBusIds != null)
                {
                    mapperRegistry.AddMapper(BusRouter.EdgeDescriptorDpKey, originalBusIds);
                }
                mapperRegistry.RemoveMapper(BusRouter.DefaultAffectedEdgesDpKey);
                if (originalEdgeSubsetMapper != null)
                {
                    mapperRegistry.AddMapper(BusRouter.DefaultAffectedEdgesDpKey, originalEdgeSubsetMapper);
                }
            }
        }
Exemplo n.º 47
0
        /// <summary>Expert: merges the clauses of a set of BooleanQuery's into a single
        /// BooleanQuery.
        /// 
        /// <p/>A utility for use by <see cref="Combine(Query[])" /> implementations.
        /// </summary>
        public static Query MergeBooleanQueries(params BooleanQuery[] queries)
        {
            var allClauses = new System.Collections.Generic.HashSet<BooleanClause>();
            foreach (BooleanQuery booleanQuery in queries)
            {
                foreach (BooleanClause clause in booleanQuery)
                {
                    allClauses.Add(clause);
                }
            }

            bool coordDisabled = queries.Length == 0?false:queries[0].IsCoordDisabled();
            BooleanQuery result = new BooleanQuery(coordDisabled);
            foreach(BooleanClause clause in allClauses)
            {
                result.Add(clause);
            }
            return result;
        }
Exemplo n.º 48
0
        void BadXmlValueTest()
        {
            var sb = new System.Text.StringBuilder();

            var forbidden = new System.Collections.Generic.HashSet <int>();
            int start = 64976; int end = 65007;

            for (int i = start; i <= end; i++)
            {
                forbidden.Add(i);
            }

            forbidden.Add(0xFFFE);
            forbidden.Add(0xFFFF);

            for (int i = char.MinValue; i <= char.MaxValue; i++)
            {
                char c = Convert.ToChar(i);
                if (char.IsSurrogate(c))
                {
                    continue; // skip surrogates
                }

                if (forbidden.Contains(c))
                {
                    continue;
                }

                sb.Append(c);
            }

            var badString = sb.ToString();

            var settings = new XmlWriterSettings
            {
                Indent           = true,
                ConformanceLevel = ConformanceLevel.Fragment,
                IndentChars      = "  ",
            };

            sb.Length = 0;
            using (XmlWriter xtw = XmlWriter.Create(sb, settings))
            {
                xtw.WriteStartElement("log4j", "event", "http:://hello/");
                xtw.WriteElementSafeString("log4j", "message", "http:://hello/", badString);
                xtw.WriteEndElement();
                xtw.Flush();
            }

            string goodString = null;

            using (XmlReader reader = XmlReader.Create(new StringReader(sb.ToString())))
            {
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Text)
                    {
                        if (reader.Value.Contains("abc"))
                        {
                            goodString = reader.Value;
                        }
                    }
                }
            }

            Assert.NotNull(goodString);
            Assert.NotEqual(badString.Length, goodString.Length);
            Assert.Contains("abc", badString);
            Assert.Contains("abc", goodString);
        }
Exemplo n.º 49
0
        public void TypoTest()
        {
            var s1 = "abcd";
            var s2 = "zdcd";

            var ss = LongestCommonSubsequence.LeftAlignedLCS(s1, s2);
            var typos = LongestCommonSubsequence.GetTypos(ss, s1, s2);

            OptChar[] keys = { OptChar.None, new OptChar('a'), new OptChar('b'), new OptChar('c'), new OptChar('d') };
            char[] values = { 'z', 'd', 'c', 'd' };

            var key_hs = new System.Collections.Generic.HashSet<OptChar>(keys);
            var value_hs = new System.Collections.Generic.HashSet<char>(values);

            var keys_seen = new System.Collections.Generic.HashSet<OptChar>();
            var values_seen = new System.Collections.Generic.HashSet<char>(); ;
            foreach (var typo in typos)
            {
                var key = typo.Item1;
                var str = typo.Item2;
                keys_seen.Add(key);
                foreach (char c in str)
                {
                    values_seen.Add(c);
                }
            }

            Assert.AreEqual(true, key_hs.SetEquals(keys_seen));
            Assert.AreEqual(true, value_hs.SetEquals(values_seen));
        }
Exemplo n.º 50
0
        /// <summary>
        /// Default constructor. Protected due to required properties, but present because EF needs it.
        /// </summary>
        protected Child()
        {
            Children = new System.Collections.Generic.HashSet <Testing.Child>();

            Init();
        }
Exemplo n.º 51
0
        void BadXmlValueTest()
        {
            var sb = new System.Text.StringBuilder();

            var forbidden = new System.Collections.Generic.HashSet<int>();
            int start = 64976; int end = 65007;

            for (int i = start; i <= end; i++)
            {
                forbidden.Add(i);
            }

            forbidden.Add(0xFFFE);
            forbidden.Add(0xFFFF);

            for (int i = char.MinValue; i <= char.MaxValue; i++)
            {
                char c = Convert.ToChar(i);
                if (char.IsSurrogate(c))
                {
                    continue; // skip surrogates
                }

                if (forbidden.Contains(c))
                {
                    continue;
                }

                sb.Append(c);
            }

            var badString = sb.ToString();

            var settings = new XmlWriterSettings
            {
                Indent = true,
                ConformanceLevel = ConformanceLevel.Fragment,
                IndentChars = "  ",
            };

            sb.Clear();
            using (XmlWriter xtw = XmlWriter.Create(sb, settings))
            {
                xtw.WriteStartElement("log4j", "event", "http:://hello/");
                xtw.WriteElementSafeString("log4j", "message", "http:://hello/", badString);
                xtw.WriteEndElement();
                xtw.Flush();
            }

            string goodString = null;
            using (XmlReader reader = XmlReader.Create(new StringReader(sb.ToString())))
            {
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Text)
                    {
                        if (reader.Value.Contains("abc"))
                            goodString = reader.Value;
                    }
                }
            }

            Assert.NotNull(goodString);
            Assert.NotEqual(badString.Length, goodString.Length);
            Assert.True(badString.Contains("abc"));
            Assert.True(goodString.Contains("abc"));
        }
Exemplo n.º 52
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public Entity5()
        {
            Entity2 = new System.Collections.Generic.HashSet <global::Sandbox.Entity2>();

            Init();
        }
 public System.Collections.Generic.ICollection<DocFieldConsumerPerField> Fields()
 {
     System.Collections.Generic.ICollection<DocFieldConsumerPerField> fields =
         new System.Collections.Generic.HashSet<DocFieldConsumerPerField>();
     for (int i = 0; i < fieldHash.Length; i++)
     {
         DocFieldProcessorPerField field = fieldHash[i];
         while (field != null)
         {
             fields.Add(field.consumer);
             field = field.next;
         }
     }
     System.Diagnostics.Debug.Assert(fields.Count == totalFieldCount);
     return fields;
 }
Exemplo n.º 54
0
    IEnumerator Start()
    {
        getDeaths.pointsAlreadyAdded = new System.Collections.Generic.HashSet<Vector3>();
        return paintGraves();

        //position death star
        if (PlayerPrefs.HasKey("last_death_x") && PlayerPrefs.HasKey("last_death_y") && PlayerPrefs.HasKey("last_death_z")){
            Instantiate(Resources.Load("prefabs/GUI/death_star"),new Vector3(PlayerPrefs.GetFloat("last_death_x"),200,PlayerPrefs.GetFloat("last_death_z")),Quaternion.identity);
        }
    }