コード例 #1
0
        public InstanceData AddInstance(string ID, ISerializeObject SerializeObject)
        {
            InstanceData instance = new InstanceData(ID, SerializeObject);

            instances.Add(instance);
            return(instance);
        }
コード例 #2
0
    public override void OnEnable()
    {
        base.OnEnable();
        if (m_mesh == null)
        {
            return;
        }

        m_instance_data = new InstanceData();

        ReleaseGPUData();
        if (m_data_transfer_mode == DataTransferMode.Buffer)
        {
            m_instance_buffer = new InstanceBuffer();
        }
        else
        {
            m_instance_texture = new InstanceTexture();
            if (m_data_transfer_mode == DataTransferMode.TextureWithMesh)
            {
                m_data_transfer_mesh = BatchRendererUtil.CreateDataTransferMesh(m_max_instances);
            }
        }

        ResetGPUData();
    }
コード例 #3
0
        protected override void ReadInstanceData(long offset)
        {
            Stream.Position   = offset;
            InternalInstances = new Dictionary <uint, InstanceData>();

            using (BinaryReader reader = new BinaryReader(Stream, Encoding.UTF8, true)) {
                Types.Generic.Version1.STUHeader data = reader.Read <Types.Generic.Version1.STUHeader>();

                Types.Generic.Version1.STUInstanceRecord[] records = new Types.Generic.Version1.STUInstanceRecord[data.InstanceCount];
                InstanceData = new InstanceData[data.InstanceCount];

                for (int i = 0; i < data.InstanceCount; i++)
                {
                    try {
                        records[i] = reader.Read <Types.Generic.Version1.STUInstanceRecord>();
                    } catch (ArgumentOutOfRangeException) {
                        break;
                    }
                }

                int index = 0;
                foreach (Types.Generic.Version1.STUInstanceRecord record in records)
                {
                    if (record.Offset + 4 > reader.BaseStream.Length || record.Offset < 0)
                    {
                        index++;
                        continue;
                    }
                    reader.BaseStream.Position = record.Offset;
                    uint checksum = reader.ReadUInt32();
                    InstanceData[index] = GetInstanceData(checksum);
                    index++;
                }
            }
        }
コード例 #4
0
ファイル: Gates.cs プロジェクト: weerox/logik
        public GateTransaction CreateAddGateTransaction(Wires wires, InstanceData gate)
        {
            // FIXME: This transaction will have to modify wires too
            // Should we bundle the wire edits necessary into this transaction
            // or should that be handled somewhere else?
            // Because we don't have access to the wires here we might want to
            // do the wires sync outside of this class in like CircuitEditor.

            if (Components.TryGetValue(gate.Type, out var component) == false)
            {
                throw new System.ComponentModel.InvalidEnumArgumentException(nameof(gate.Type), (int)gate.Type, typeof(ComponentType));
            }

            Span <Vector2i> ports = stackalloc Vector2i[component !.NumberOfPorts];

            component !.GetPorts(ports);

            // FIXME: Consider orientation
            // Move the ports to be not be relative to the component
            for (int i = 0; i < ports.Length; i++)
            {
                ports[i] += gate.Position;
            }

            var wTransaction = wires.CreateAddConnectionPointsTransaction(ports);

            // FIXME: Do some de-duplication stuff?
            return(new GateTransaction(false, gate, wTransaction));
        }
コード例 #5
0
        public void Update(InstanceDataCollection id)
        {
            var data = new InstanceData[id.Count];

            id.CopyTo(data, 0);
            Name.Value = id.CounterName;

            foreach (var v in data)
            {
                if (!valueDictionary.ContainsKey(v.InstanceName))
                {
                    valueDictionary.Add(v.InstanceName, new InstanceValueViewModel(v.InstanceName, Processor));
                }
                valueDictionary[v.InstanceName].Update(v);
            }

            var ordered = valueDictionary.Values.OrderByDescending(v => v.Value.Value).ToList();

            Name.Value += " (" + ordered.FirstOrDefault()?.Value.Value.ToString("#######0.##") + ")";

            if (Selected.Value)
            {
                Values.Value = ordered;
            }
        }
コード例 #6
0
        public void AddItemTest()
        {
            InstanceData instance = new InstanceData();

            instance.Name            = "MyName";
            instances[instance.Name] = instance;
        }
コード例 #7
0
ファイル: LazyCounter.cs プロジェクト: tonythegreat/Methods
 ///<summary>Constructs a lazy counter with an initial count and an optional enumerator to count more items from.</summary>
 public LazyCounter(long countSoFar = 0, IEnumerator countAdvancer = null)
 {
     this._data = new InstanceData {
         CountSoFar    = countSoFar,
         CountAdvancer = countAdvancer
     };
 }
コード例 #8
0
 /// <summary>
 /// Creates output files. Some final generation still happens here so extra data is needed.
 /// </summary>
 /// <param name="instance"></param>
 /// <param name="enemies">Needed to create enemy links.</param>
 /// <param name="relatedPaths">Needed to create the navigation bar.</param>
 public static void CreateFiles(InstanceData instance, List<Enemy> enemies, List<PathData> relatedPaths)
 {
     instance = CreateLinks(instance, enemies);
       foreach (var path in instance.Paths)
       {
     var encounterCounter = 0;
     var encounterFile = new StringBuilder();
     encounterFile.Append("GUIDE").Append(Constants.Delimiter).Append(path.FractalScale).Append(Constants.ForcedLineEnding);
     encounterFile.Append(Helper.ConvertSpecial(path.InstanceName)).Append(Constants.Delimiter).Append(Helper.ConvertSpecial(path.NavigationName)).Append(Constants.ForcedLineEnding);
     encounterFile.Append(GenerateNavigationInfo(path, relatedPaths));
     encounterFile.Append(Constants.InitialdataHtml);
     var pathEncounters = instance.Encounters.Where(encounter => encounter.Paths.Contains(path.Tag.ToLower()) && encounter.Tactics.IsAvailableForScale(path.FractalScale));
     foreach (var encounter in pathEncounters)
     {
       encounter.CopyToEnemyTactics(enemies);
       encounterFile.Append(encounter.ToHtml(encounterCounter, pathEncounters, path.FractalScale, path.Map));
       encounterCounter++;
     }
     var fileName = Constants.DataOutput + Constants.DataEncounterResult + path.Filename.ToLower() + ".htm";
     var directory = Path.GetDirectoryName(fileName);
     if (directory != null)
       Directory.CreateDirectory(directory);
     try
     {
       File.WriteAllText(fileName, encounterFile.ToString());
     }
     catch (UnauthorizedAccessException)
     {
       ErrorHandler.ShowWarningMessage("File " + fileName + " in use.");
     }
       }
 }
コード例 #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CircuitContext"/> class.
 /// </summary>
 /// <param name="contextName">Name of the context.</param>
 /// <param name="parent">Parent of the context.</param>
 /// <param name="evaluator">Circuit evaluator.</param>
 /// <param name="simulationPreparations">Simulation preparations.</param>
 /// <param name="resultService">SpiceModel service for the context.</param>
 /// <param name="nameGenerator">Name generator for the models.</param>
 /// <param name="statementsReader">Statements reader.</param>
 /// <param name="waveformReader">Waveform reader.</param>
 /// <param name="caseSettings">Case settings.</param>
 /// <param name="exporters">Exporters.</param>
 /// <param name="workingDirectory">Working directory.</param>
 /// <param name="instanceData">Instance data.</param>
 public CircuitContext(
     string contextName,
     ICircuitContext parent,
     ICircuitEvaluator evaluator,
     ISimulationPreparations simulationPreparations,
     IResultService resultService,
     INameGenerator nameGenerator,
     ISpiceStatementsReader statementsReader,
     IWaveformReader waveformReader,
     ISpiceNetlistCaseSensitivitySettings caseSettings,
     IMapper <Exporter> exporters,
     string workingDirectory,
     InstanceData instanceData)
 {
     Name      = contextName ?? throw new ArgumentNullException(nameof(contextName));
     Evaluator = evaluator;
     SimulationPreparations = simulationPreparations;
     Result               = resultService ?? throw new ArgumentNullException(nameof(resultService));
     NameGenerator        = nameGenerator ?? throw new ArgumentNullException(nameof(nameGenerator));
     Parent               = parent;
     Children             = new List <ICircuitContext>();
     CaseSensitivity      = caseSettings;
     StatementsReader     = statementsReader;
     WaveformReader       = waveformReader;
     AvailableSubcircuits = CreateAvailableSubcircuitsCollection();
     ModelsRegistry       = CreateModelsRegistry();
     Exporters            = exporters;
     WorkingDirectory     = workingDirectory;
     InstanceData         = instanceData;
 }
コード例 #10
0
    // Display the contents of an InstanceDataCollection.
    public static void ProcessInstanceDataCollection(InstanceDataCollection idCol)
    {
        ICollection idColKeys = idCol.Keys;

        string[] idColKeysArray = new string[idColKeys.Count];
        idColKeys.CopyTo(idColKeysArray, 0);

        ICollection idColValues = idCol.Values;

        InstanceData[] idColValuesArray = new InstanceData[idColValues.Count];
        idColValues.CopyTo(idColValuesArray, 0);

        Console.WriteLine("  InstanceDataCollection for \"{0}\" " +
                          "has {1} elements.", idCol.CounterName, idCol.Count);

        // Display the InstanceDataCollection Keys and Values.
        // The Keys and Values collections have the same number of elements.
        int index;

        for (index = 0; index < idColKeysArray.Length; index++)
        {
            Console.WriteLine("    Next InstanceDataCollection " +
                              "Key is \"{0}\"", idColKeysArray[index]);
            ProcessInstanceDataObject(idColValuesArray[index]);
        }
    }
コード例 #11
0
        public override void OnEnable()
        {
            base.OnEnable();
            if (m_mesh == null)
            {
                return;
            }

            if (m_data_transfer_mode == DataTransferMode.Buffer && !SystemInfo.supportsComputeShaders)
            {
                Debug.Log("BatchRenderer: ComputeBuffer is not available. fallback to Texture data transfer mode.");
                m_data_transfer_mode = DataTransferMode.Texture;
            }
            if (m_data_transfer_mode == DataTransferMode.TextureWithPlugin && !BatchRendererUtil.IsCopyToTextureAvailable())
            {
                Debug.Log("BatchRenderer: CopyToTexture plugin is not available. fallback to Texture data transfer mode.");
                m_data_transfer_mode = DataTransferMode.Texture;
            }

            m_instance_data = new InstanceData();
            if (m_data_transfer_mode == DataTransferMode.Buffer)
            {
                m_instance_buffer = new InstanceBuffer();
            }
            else
            {
                m_instance_texture = new InstanceTexture();
            }

            ResetGPUData();
        }
コード例 #12
0
        private static int CompareFunc(InstanceData x, InstanceData y)
        {
            if (x.InstanceNumber == null)
            {
                if (y.InstanceNumber == null)
                {
                    return(0);
                }
                else
                {
                    return(-1);
                }
            }
            else
            {
                if (y.InstanceNumber == null)
                {
                    return(1);
                }
                else
                {
                    int retval = x.InstanceNumber.Length.CompareTo(y.InstanceNumber.Length);

                    if (retval != 0)
                    {
                        return(retval);
                    }
                    else
                    {
                        return(x.InstanceNumber.CompareTo(y.InstanceNumber));
                    }
                }
            }
        }
コード例 #13
0
        protected EmailLuis CreateIntent(
            string userInput,
            Intent intent        = Intent.None,
            double[] ordinal     = null,
            double[] number      = null,
            string[] contactName = null,
            string[] senderName  = null,
            string[] emailAdress = null,
            string[] subject     = null,
            string[] message     = null)
        {
            var emailIntent = new EmailLuis
            {
                Text = userInput,

                Intents = new Dictionary <Intent, IntentScore>()
            };

            emailIntent.Intents.Add(intent, new IntentScore()
            {
                Score = TopIntentScore
            });

            emailIntent.Entities = new _Entities
            {
                _instance = new _Entities._Instance(),

                ordinal      = ordinal,
                number       = number,
                ContactName  = contactName,
                SenderName   = senderName,
                EmailSubject = subject,
                Message      = message
            };

            if (!string.IsNullOrEmpty(userInput))
            {
                emailIntent.Entities.email = emailAdress;
                if (emailAdress != null)
                {
                    emailIntent.Entities._instance.email = new InstanceData[emailAdress.Length];

                    for (int i = 0; i < emailAdress.Length; i++)
                    {
                        var email      = emailAdress[i];
                        var startIndex = userInput.IndexOf(email);
                        var endIndex   = userInput.IndexOf(email) + email.Length;

                        InstanceData originalEmailAdress = new InstanceData()
                        {
                            StartIndex = startIndex,
                            EndIndex   = endIndex
                        };
                        emailIntent.Entities._instance.email[i] = originalEmailAdress;
                    }
                }
            }

            return(emailIntent);
        }
コード例 #14
0
ファイル: XorGate.cs プロジェクト: NogginBops/logik
        public void Draw(Context cr, InstanceData data)
        {
            using var transform = IComponentGraphics.ApplyComponentTransform(cr, data);

            //foreach (var gate in instances)
            {
                cr.MoveTo(-27.5, -15);
                cr.RelLineTo(7.5, 0);
                cr.RelCurveTo(10, 0, 15, 7.5, 20, 15);
                cr.RelCurveTo(-5, 7.5, -10, 15, -20, 15);
                cr.RelLineTo(-7.5, 0);
                cr.RelCurveTo(0, 0, 5, -7.5, 5, -15);
                cr.RelCurveTo(0, -7.5, -5, -15, -5, -15);
                cr.ClosePath();
                cr.RelMoveTo(-5, 30);
                cr.RelCurveTo(0, 0, 5, -7.5, 5, -15);
                cr.RelCurveTo(0, -7.5, -5, -15, -5, -15);
            }
            cr.SetSourceRGB(0.1, 0.1, 0.1);
            cr.LineWidth = Wires.WireWidth;
            cr.Stroke();

            //foreach (var gate in instances)
            {
                Span <Vector2i> points = stackalloc Vector2i[NumberOfPorts];
                GetPorts(points);

                for (int i = 0; i < NumberOfPorts; i++)
                {
                    IComponentGraphics.DrawRoundPort(cr, data, points, i);
                }
            }
        }
コード例 #15
0
        public void EnumeratorCurrentTest()
        {
            InstanceData instance = new InstanceData();

            instance.Name             = "MyName";
            instance.DatabaseTypeName = "MyType";
            instances.Add(instance);
            InstanceData instance2 = new InstanceData();

            instance2.Name             = "MyName2";
            instance2.DatabaseTypeName = "MyType2";
            instances.Add(instance2);
            int count = 0;

            foreach (InstanceData inst in instances)
            {
                Assert.IsNotNull(inst);
                count++;
                foreach (InstanceData inst2 in instances)
                {
                    Assert.IsNotNull(inst2);
                    count++;
                }
            }
            Assert.AreEqual(6, count);
        }
コード例 #16
0
        /// <summary>
        /// Serialises all properties. The output will be a dictionary containing the
        /// objects properties in a form that can easily be converted to Json.
        /// </summary>
        ///
        /// <returns>The serialised object in dictionary form.</returns>
        public IDictionary <string, object> Serialise()
        {
            var dictionary = new Dictionary <string, object>();

            // Item Id
            dictionary.Add("ItemID", ItemId);

            // Key
            dictionary.Add("Key", Key);

            // Name
            if (Name != null)
            {
                dictionary.Add("Name", Name);
            }

            // Instance Data
            if (InstanceData != null)
            {
                dictionary.Add("InstanceData", InstanceData.Serialise());
            }

            // Write Lock
            dictionary.Add("WriteLock", WriteLock);

            return(dictionary);
        }
コード例 #17
0
        public void AddAsObjectTest()
        {
            InstanceData instance = new InstanceData();

            instance.Name = "MyName";
            instances.Add((Object)instance);
        }
コード例 #18
0
        /// <summary>
        /// <para>Gets the <see cref="DatabaseProviderData"/> for the named <see cref="InstanceData"/>.</para>
        /// </summary>
        /// <param name="instanceName">
        /// <para>The name of the <see cref="InstanceData"/> to get the data.</para>
        /// </param>
        /// <returns>
        /// <para>The <see cref="DatabaseProviderData"/> for the named <see cref="InstanceData"/>.</para>
        /// </returns>
        public virtual DatabaseProviderData GetDatabaseProviderData(string instanceName)
        {
            DatabaseSettings settings = GetDatabaseSettings();
            InstanceData     instance = settings.Instances[instanceName];

            if (null == instance)
            {
                throw new ConfigurationException(SR.ExceptionNoInstance(instanceName));
            }

            ConnectionStringData connectionString = settings.ConnectionStrings[instance.ConnectionString];

            if (null == connectionString)
            {
                throw new ConfigurationException(SR.ExceptionNoConnectionStringType(instance.ConnectionString));
            }

            DatabaseTypeData databaseType = settings.DatabaseTypes[instance.DatabaseTypeName];

            if (null == databaseType)
            {
                throw new ConfigurationException(SR.ExceptionNoDatabaesType(instance.DatabaseTypeName));
            }

            return(new DatabaseProviderData(instance, databaseType, connectionString));
        }
    private void RunCPUSorting(ref Vector3 _cameraPosition)
    {
        int index = 0;

        for (int i = 0; i < m_renderers.Length; i++)
        {
            List <InstanceData> data = m_renderers[i].computeInstances;
            int dataSize             = data.Count;

            // Update the cam to obj distances
            for (int p = 0; p < dataSize; p++)
            {
                InstanceData d = data[p];
                d.distanceToCamera = Vector3.Distance(d.position, _cameraPosition);
                data[p]            = d;
            }

            // Sort
            data.Sort(
                (a, b) =>
            {
                return(a.distanceToCamera <= b.distanceToCamera ? -1 : 1);
            }
                );

            for (int j = 0; j < dataSize; j++)
            {
                instancesPositionsArray[index] = data[j];
                index++;
            }
        }
        m_instanceDataBuffer.SetData(instancesPositionsArray);
    }
コード例 #20
0
        static float[] ExtractSamples(int categoryIndex, string counter, InstanceDataCollectionCollection[][] samples, string instance)
        {
            float[]       result    = new float[samples.Length - 1];
            CounterSample oldSample = CounterSample.Empty;

            for (int i = 0; i < samples.Length; i++)
            {
                InstanceDataCollectionCollection idcc = samples[i][categoryIndex];
                if (idcc == null)
                {
                    return(null);
                }
                InstanceDataCollection idc = idcc[counter];
                if (idc == null)
                {
                    return(null);
                }
                InstanceData id = idc[instance];
                if (id == null)
                {
                    id = idc[TruncatedAppName(instance)];
                    if (id == null)
                    {
                        return(null);
                    }
                }
                CounterSample sample = id.Sample;
                if (i > 0)
                {
                    result[i - 1] = Calculate(oldSample, sample);
                }
                oldSample = sample;
            }
            return(result);
        }
コード例 #21
0
 public override void Draw(CircuitEditor editor, Context cr)
 {
     if (PlacingComponent)
     {
         BaseComponent.Draw(cr, InstanceData.Create(BaseComponent.Type, VisualPosition, CompOrientation));
     }
 }
コード例 #22
0
        private static InstanceData[] GetInstanceDatas(string userInput, string[] entities)
        {
            if (userInput == null || entities == null)
            {
                return(null);
            }

            var result = new InstanceData[entities.Length];

            for (int i = 0; i < entities.Length; i++)
            {
                var name  = entities[i];
                var index = userInput.IndexOf(name);
                if (index == -1)
                {
                    throw new Exception("No such string in user input");
                }

                var instanceData = new InstanceData
                {
                    StartIndex = index,
                    EndIndex   = index + name.Length,
                    Text       = name
                };

                result[i] = instanceData;
            }

            return(result);
        }
        public void ResolveBlendShapes(ref InstanceData instanceData, SkinnedMeshRenderer smr)
        {
            const float rcp_100 = 1.0f / 100.0f;

            for (int i = 0; i != instanceData.blendShapeIndices.Length; i++)
            {
                int blendShapeIndex = instanceData.blendShapeIndices[i];
                if (blendShapeIndex != -1)
                {
                    instanceData.blendShapeWeights[i] = smr.GetBlendShapeWeight(blendShapeIndex) * rcp_100;
                }
                //else
                //{
                //	Debug.LogError("bad blendshape index: " + blendShapeIndex);
                //}
            }

            unsafe
            {
                fixed(void *ptrSnappersControllers = instanceData.rigControllers)
                fixed(void *ptrSnappersBlendShapes = instanceData.blendShapeWeights)
                fixed(void *ptrSnappersShaderParam = instanceData.shaderParamFloats)
                {
                    ResolveBlendShapes(ptrSnappersControllers, ptrSnappersBlendShapes, ptrSnappersShaderParam);
                }
            }
        }
        public static void ApplyControllers(ref InstanceData instanceData)
        {
            const float rcp_100 = 1.0f / 100.0f;

            for (int i = 0; i != instanceData.rigTransforms.Length; i++)
            {
                var rigTransform = instanceData.rigTransforms[i];
                if (rigTransform != null)
                {
                    Vector3 localPos;
                    Vector3 localRot;
                    Vector3 localMul;

                    localPos.x = instanceData.rigControllers[i].translateX * rcp_100 * -1.0f;                    // flip
                    localPos.y = instanceData.rigControllers[i].translateY * rcp_100;
                    localPos.z = instanceData.rigControllers[i].translateZ * rcp_100;

                    localRot.x = instanceData.rigControllers[i].rotateX * -1.0f;
                    localRot.y = instanceData.rigControllers[i].rotateY;
                    localRot.z = instanceData.rigControllers[i].rotateZ;

                    localMul.x = instanceData.rigControllers[i].scaleX;
                    localMul.y = instanceData.rigControllers[i].scaleY;
                    localMul.z = instanceData.rigControllers[i].scaleZ;

                    rigTransform.localPosition = localPos;
                    rigTransform.localRotation = Quaternion.Euler(localRot);
                    rigTransform.localScale    = localMul;
                }
                //else
                //{
                //	Debug.LogError("bad transform index: " + i);
                //}
            }
        }
コード例 #25
0
        protected override void _FillFromDataRow(System.Data.DataRow cDataRow)
        {
            JsonFxObject.Instance cJsonInst = new JsonFxObject.Instance(cDataRow[_sFieldName].ToString(), _sNodeName);

            if (cJsonInst.ContainsKey("instances"))
            {
                int i = 0;

                foreach (dynamic c in cJsonInst.DynamicObject.instances)
                {
                    i = c.pi;

                    if (_cDicInstanceData.ContainsKey(i))
                    {
                        _cDicInstanceData[i].FromExpandoObject(c);
                    }
                    else
                    {
                        InstanceData cData = new InstanceData();
                        cData.FromExpandoObject(c);
                        _cDicInstanceData.Add(i, cData);
                    }
                }
            }
        }
コード例 #26
0
        // FIXME: Cleanup and possibly split draw into a 'outline' and 'fill'
        // call so we can do more efficient cairo rendering.
        public void Draw(Context cr, InstanceData data)
        {
            using var transform = IComponentGraphics.ApplyComponentTransform(cr, data);

            //foreach (var gate in instances)
            {
                cr.MoveTo(-30, -15);
                cr.RelLineTo(30, 15);
                cr.RelLineTo(-30, 15);
                cr.ClosePath();
            }

            // FIXME: We probably shouldn't hardcode the color
            cr.SetSourceRGB(0.1, 0.1, 0.1);
            cr.LineWidth = Wires.WireWidth;
            cr.Stroke();

            //foreach (var gate in instances)
            {
                Span <Vector2i> points = stackalloc Vector2i[NumberOfPorts];
                GetPorts(points);

                for (int i = 0; i < NumberOfPorts; i++)
                {
                    IComponentGraphics.DrawRoundPort(cr, data, points, i);
                }
            }
        }
コード例 #27
0
        /// <summary>
        /// Creates a named database instance from the data configuration types
        /// </summary>
        /// <param name="instanceName">The instance name to use for the database</param>
        /// <param name="connectionData">The connection string data</param>
        /// <param name="providerData">The type provider data</param>
        /// <returns>An initialized database provider</returns>
        public static Database CreateDatabase(string instanceName, ConnectionStringData connectionData, DatabaseTypeData providerData)
        {
            ArgumentValidation.CheckForEmptyString(instanceName, "Instance Name");
            ArgumentValidation.CheckForNullReference(connectionData, "Connection Data");
            ArgumentValidation.CheckForNullReference(providerData, "Provider Data");

            DatabaseSettings settings = new DatabaseSettings();

            // Setup the provider and connection string data
            settings.DatabaseTypes.Add(providerData);
            settings.ConnectionStrings.Add(connectionData);

            // The instance data binds the provider and connection string together
            InstanceData instanceData = new InstanceData();

            instanceData.ConnectionString = connectionData.Name;
            instanceData.DatabaseTypeName = providerData.Name;
            instanceData.Name             = instanceName;

            // setup your instanceData
            settings.Instances.Add(instanceData);

            // Setup a data dictionary
            ConfigurationDictionary configDictionary = new ConfigurationDictionary();

            configDictionary.Add(_configName, settings);
            ConfigurationContext context = ConfigurationManager.CreateContext(configDictionary);

            return(new DatabaseProviderFactory(context).CreateDatabase(instanceName));
        }
コード例 #28
0
        public VertexCache.InstancingPackage CreatePackage(InstanceData data, Mesh mesh, Material[] originalMaterial, int index)
        {
            VertexCache.InstancingPackage package = new VertexCache.InstancingPackage();
            package.material     = new Material[mesh.subMeshCount];
            package.subMeshCount = mesh.subMeshCount;
            package.size         = 1;
            for (int i = 0; i != mesh.subMeshCount; ++i)
            {
#if USE_CONSTANT_BUFFER
                package.material[i] = new Material(originalMaterial[i]);
                //package.material[i].name = "AniInstancing";
#if UNITY_5_6_OR_NEWER
                package.material[i].enableInstancing = UseInstancing;
#endif
                if (UseInstancing)
                {
                    package.material[i].EnableKeyword("INSTANCING_ON");
                }
                else
                {
                    package.material[i].DisableKeyword("INSTANCING_ON");
                }

                package.propertyBlock = new MaterialPropertyBlock();
                package.material[i].EnableKeyword("USE_CONSTANT_BUFFER");
                package.material[i].DisableKeyword("USE_COMPUTE_BUFFER");
#endif
            }

            Matrix4x4[] mat        = new Matrix4x4[instancingPackageSize];
            float[]     frameIndex = new float[instancingPackageSize];
            data.worldMatrix[index].Add(mat);
            data.frameIndex[index].Add(frameIndex);
            return(package);
        }
コード例 #29
0
        //TODO: use read only sizes instad of hardcoded numbers
        public static DeviceBuffer AllocateInstanceDataBuffer(InstanceData instanceData, GraphicsDevice graphicsDevice, ResourceFactory resourceFactory)
        {
            DeviceBuffer deviceBuffer = null;

            switch (instanceData.Flag)
            {
            case InstancingDataFlags.EMPTY:
                break;

            case InstancingDataFlags.POSITION:
                deviceBuffer = resourceFactory.CreateBuffer(new BufferDescription(instanceData.Positions.Length.ToUnsigned() * 12, BufferUsage.VertexBuffer));
                graphicsDevice.UpdateBuffer(deviceBuffer, 0, instanceData.Positions);
                break;

            case InstancingDataFlags.VIEW_MATRICES:
                deviceBuffer = resourceFactory.CreateBuffer(new BufferDescription(instanceData.ViewMatrices.Length.ToUnsigned() * 64, BufferUsage.VertexBuffer));
                graphicsDevice.UpdateBuffer(deviceBuffer, 0, instanceData.ViewMatrices);
                break;

            default:
                throw new NotImplementedException($"{instanceData.Flag.ToString("g")} not implemented");
            }

            return(deviceBuffer);
        }
コード例 #30
0
        /// <summary>
        /// Clone the entity.
        /// </summary>
        /// <param name="data">Instancing data.</param>
        /// <returns></returns>
        public override Entity Clone(InstanceData data)
        {
            var result = (BehavioralComponent)base.Clone(data);

            result.ParameterSets.Get <BaseParameters>().Instance = data;
            return(result);
        }
コード例 #31
0
ファイル: QueryProcessor.cs プロジェクト: sakpung/webstudy
        void find_MatchInstance
        (
            object sender,
            MatchEventArgs <CompositeObjectInstance> e
        )
        {
            try
            {
                InstanceData instance = new InstanceData( );

                instance.InstanceNumber    = e.Info.InstanceNumber.ToString( );
                instance.PatientID         = e.Dataset.GetValue <string> (DicomTag.PatientID, string.Empty);
                instance.SeriesInstanceUID = e.Info.SeriesInstanceUID;
                instance.SOPClassUID       = e.Info.SOPClassUID;
                instance.SOPInstanceUID    = e.Info.SOPInstanceUID;
                instance.StationName       = e.Dataset.GetValue <string> (DicomTag.StationName, string.Empty);
                instance.StudyInstanceUID  = e.Dataset.GetValue <string> (DicomTag.StudyInstanceUID, string.Empty);
                instance.TransferSyntax    = e.Dataset.GetValue <string> (DicomTag.TransferSyntaxUID, string.Empty);

                Matches.Add(instance as T);
            }
            catch (Exception exception)
            {
                System.Diagnostics.Debug.Assert(false, exception.Message);

                throw;
            }
        }
コード例 #32
0
 public void AddRemoveTest()
 {
     InstanceData instance = new InstanceData();
     instance.Name = "MyName";
     instances.Add(instance);
     Assert.AreEqual(1, instances.Count);
     instances.Remove(instance.Name);
 }
コード例 #33
0
 public void ClearTest()
 {
     InstanceData instance = new InstanceData();
     instance.Name = "MyName";
     instances.Add(instance);
     Assert.AreEqual(1, instances.Count);
     instances.Clear();
     Assert.AreEqual(0, instances.Count);
 }
コード例 #34
0
    private Mesh BakeMesh(InstanceData[] instances)
    {
        if (meshFilter == null)
        {
            meshFilter = GetComponent<MeshFilter>();
        }

        Mesh mesh = new Mesh();
        var meshVertices = meshFilter.sharedMesh.vertices;
        var meshUVs = meshFilter.sharedMesh.uv;
        var indices = meshFilter.sharedMesh.GetIndices(0);
        var normals = meshFilter.sharedMesh.normals;

        var vertexData = new List<Vector3>();
        var normalData = new List<Vector3>();
        var uv0Data = new List<Vector2>();

        for (int instanceIdx = 0; instanceIdx < instances.Length; instanceIdx++)
        {
            var scale = Vector3.Lerp(minScale, maxScale, UnityEngine.Random.value);
            var cur = instances[instanceIdx];

            var instancePos = new Vector3(Mathf.Cos(cur.startAngle), cur.verticalOffset, Mathf.Sin(cur.startAngle)) * cur.ringRadius;

            var instanceRotation = Quaternion.AngleAxis(UnityEngine.Random.value * 360, UnityEngine.Random.insideUnitSphere);

            vertexData.AddRange(meshVertices.Select(v => instancePos + instanceRotation * (new Vector3(v.x * scale.x, v.y * scale.y, v.z * scale.z) * meshScale)));
            normalData.AddRange(normals.Select(v => Vector3.Normalize(instanceRotation * new Vector3(v.x * scale.x, v.y * scale.y, v.z * scale.z) * meshScale)));
            uv0Data.AddRange(meshUVs);
        }

            mesh.SetVertices(vertexData);
        mesh.SetIndices(Enumerable.Range(0, instances.Length).SelectMany(i => indices.Select(vi => i * meshVertices.Length + vi)).ToArray(), MeshTopology.Triangles, 0);
        mesh.SetUVs(0, uv0Data);
            mesh.SetNormals(normalData);

        mesh.RecalculateNormals();
        mesh.RecalculateBounds();

        mesh.Optimize();

        return mesh;
    }
コード例 #35
0
 /// <summary>
 /// Converts raw encounter data to objects.
 /// </summary>
 public static InstanceData ReadInstance(string location, string instance, List<Enemy> enemies)
 {
     string[] lines = Helper.ReadFile(location + instance + ".txt");
       if (lines == null)
     return null;
       var encounterData = new InstanceData();
       for (var row = 0; row < lines.Length; row++)
       {
     ErrorHandler.InitializeWarningSystem(row + 1, lines[row]);
     HandleLine(lines[row], encounterData.Encounters, encounterData.Paths, instance);
       }
       // This code is also used for non-instances which don't have paths.
       // So add a fake path to make everything work correctly.
       // TODO: Figure out why this is necessary and refactor.
       if (encounterData.Paths.Count == 0)
     encounterData.Paths.Add(new PathData(instance, instance));
       // Set unique indexes so HTML tabs get unique IDs.
       for (var i = 0; i < encounterData.Encounters.Count; i++)
     encounterData.Encounters[i].Index = i + Constants.UniqueIndexCounter;
       Constants.UniqueIndexCounter += encounterData.Encounters.Count;
       return encounterData;
 }
コード例 #36
0
 public void EnumeratorCurrentTest()
 {
     InstanceData instance = new InstanceData();
     instance.Name = "MyName";
     instance.DatabaseTypeName = "MyType";
     instances.Add(instance);
     InstanceData instance2 = new InstanceData();
     instance2.Name = "MyName2";
     instance2.DatabaseTypeName = "MyType2";
     instances.Add(instance2);
     int count = 0;
     foreach (InstanceData inst in instances)
     {
         Assert.IsNotNull(inst);
         count++;
         foreach (InstanceData inst2 in instances)
         {
             Assert.IsNotNull(inst2);
             count++;
         }
     }
     Assert.AreEqual(6, count);
 }
コード例 #37
0
ファイル: SampleInfo1.cs プロジェクト: shizhexu/opensplice
	    private void determineGenerationRank (InstanceData instanceData, SampleData mrs, SampleData mrsic)
	    {
	        GenerationRankActionArg arg = new GenerationRankActionArg();
	
	        if ((instanceData != null) && (mrs != null) && (mrsic != null)) {
	            arg.mrsCount   = mrs.DisposedGenerationCount + mrs.NoWritersGenerationCount;
	            arg.mrsicCount = mrsic.DisposedGenerationCount + mrsic.NoWritersGenerationCount;
	
	            foreach (SampleData sampleData in instanceData.expected) {
	                determineGenerationRankAction(sampleData, arg);
	            }
	        }
	    }
	public void CopyTo(InstanceData[] instances, int index) {}
コード例 #39
0
ファイル: NSTMgt.cs プロジェクト: kine/NAV_NST_Management
        public void Create()
        {
            InstanceData instanceData = new InstanceData();
            if (instanceData.ShowDialog(null) == System.Windows.Forms.DialogResult.OK)
            {
                string name = instanceData.ServiceName;
                string caption = name;
                string type = instanceData.StartType;
                string start = instanceData.StartType;
                string db = instanceData.DBName;
                string server = instanceData.ServerName;
                string path = CreateNewDir(name);
                string serviceType;

                if (instanceData.CreateNST && instanceData.CreateWS)
                {
                    serviceType = "share";
                }
                else
                {
                    serviceType = "own";
                }

                if (instanceData.CreateNST)
                {

                    CreateNewService(name, start, path, serviceType);
                    NAVService serviceItem = new NAVService("MicrosoftDynamicsNavServer$" + name,machineName);

                    //serviceItem.GetDetails();
                    serviceItem.DB = db;
                    serviceItem.Server = server;
                    serviceItem.UpdateConfig();

                }
                if (instanceData.CreateWS)
                {

                    CreateNewWS(name, start, path, serviceType);
                    if (!instanceData.CreateNST)
                    {
                        NAVService serviceItem = new NAVService("MicrosoftDynamicsNAVWS$" + name,machineName);
                        serviceItem.DB = db;
                        serviceItem.Server = server;
                        serviceItem.UpdateConfig();
                    }
                }
            }
        }
コード例 #40
0
    public void OnEnable()
    {
        if (!SystemInfo.supportsComputeShaders)
        {
            Debug.Log("ProceduralGBuffer: ComputeBuffer is not available.");
        }

        if (m_mesh == null) return;

        m_instance_data = new InstanceData();
        m_instance_buffer = new InstanceBuffer();

        ResetGPUData();
    }
コード例 #41
0
 /// <summary>
 /// Replaces enemy and other link tags with html.
 /// </summary>
 public static InstanceData CreateLinks(InstanceData instance, List<Enemy> enemies)
 {
     foreach (var encounter in instance.Encounters)
     encounter.CreateLinks(encounter.Paths, enemies);
       return instance;
 }
コード例 #42
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Tab))
        {
            SmoothFollow sf = Camera.main.GetComponent<SmoothFollow>();

            if (sf.IsFollowing() == false)
                sf.SetTarget(R2D2.transform);
            else
                sf.SetTarget(null);

        }
        // Move R2D2
        if (instances.Count > 0 && R2D2 != null)
        {
            if (CompareVectors(agent.destination, initR2D2Pos))
            {
                agent.SetDestination(instances[curInstance].transform.position + instances[curInstance].transform.forward);
            }
            else if (agent.remainingDistance == 0F)
            {
                countdown -= Time.deltaTime;

                if (countdown <= 0.0f)
                {
                    string now = DateTime.Now.ToString("H:mm:ss");
                    countdown = 2.0f;
                    InstanceData message = new InstanceData();
                    message.message = now + " R2D2: " + instanceList[curInstance].description;
                    message.status = instanceList[curInstance].status;

                    messageList.Add(message);

                    if (curInstance + 1 == instances.Count)
                        curInstance = 0;
                    else
                        curInstance++;
                    agent.SetDestination(instances[curInstance].transform.position + instances[curInstance].transform.forward);

                    if (messageList.Count > 5)
                        messageList.RemoveAt(0);
                }
            }
        }

        // Check if new commands arrived
        if (mainController && lastUpdate != mainController.lastUpdate)
        {
            commands.Clear();

            foreach (string c in mainController.commands)
            {
                commands.Add(c);
            }
            lastUpdate = mainController.lastUpdate;
        }
        // Deal with received commands
        foreach (string elem in commands)
        {
            string[] data = elem.Split(';');

            if (data.Length > 1)
            {
                string command = data[0];

                if (command == "SERVER_1.0")
                {
                    Text nameText, roleText, locationText;
                    string x = data[1];
                    string z = data[2];
                    string rotation = data[3];
                    string name = data[4];
                    string role = data[5];
                    string location = data[6];
                    string status = data[7]; // Status can be 0,1,2,3,4 (4 being the most critical: fire)
                    string type = data[8];   // Type can be 0,1,2
                    string description = data[9];

                    bool found = false;
                    foreach (InstanceData i in instanceList)
                    {
                        if (i.name == name)
                        {
                            found = true;
                            break;
                        }
                    }

                    if (found == false)
                    {
                        InstanceData instanceData = new InstanceData();
                        instanceData.description = description;
                        instanceData.name = name;
                        instanceData.role = role;
                        instanceData.status = status;

                        instanceList.Add(instanceData);

                        //Debug.LogFormat("Command {0} {1} {2} {3} {4} {5}", command, name, x, z, status, description);
                        GameObject serverPrefab;
                        switch (type)
                        {
                            default:
                            case "0":
                                serverPrefab = serverPrefab0;
                                break;
                            case "1":
                                serverPrefab = serverPrefab1;
                                break;
                            case "2":
                                serverPrefab = serverPrefab2;
                                break;
                        }

                        // Special case for type 2 as the original model is weirdo
                        GameObject instance;
                        if (type != "2")
                        {
                            instance = (GameObject)Instantiate(serverPrefab, new Vector3(int.Parse(x), yPos, int.Parse(z)), new Quaternion(0, 0, 0, 0));
                            instance.transform.Rotate(new Vector3(0, 180 + int.Parse(rotation), 0));
                        }
                        else
                        {
                            float type2yPos = 3.3F;
                            instance = (GameObject)Instantiate(serverPrefab, new Vector3(int.Parse(x), type2yPos, int.Parse(z)), new Quaternion(0, 0, 0, 0));

                            instance.transform.Rotate(new Vector3(0, -140 + int.Parse(rotation), 0));
                        }
                        instances.Add(instance);
                        Transform[] allChildren = instance.GetComponentsInChildren<Transform>();
                        foreach (Transform child in allChildren)
                        {
                            if (child.name == "Name")
                            {
                                nameText = child.GetComponent<Text>();
                                nameText.text = name;
                                if (status.Contains("4"))
                                {
                                    nameText.color = Color.red;
                                }
                                else if (status.Contains("3"))
                                {
                                    Color color = new Color();
                                    ColorUtility.TryParseHtmlString("#FF8F18FF", out color);
                                    nameText.color = color;
                                }
                                else if (status.Contains("2"))
                                {
                                    nameText.color = Color.yellow;
                                }
                                else if (status.Contains("1"))
                                {
                                    nameText.color = Color.blue;
                                }
                                else if (status.Contains("0"))
                                {
                                    nameText.color = Color.green;
                                }
                            }
                            if (child.name == "Role")
                            {
                                roleText = child.GetComponent<Text>();
                                roleText.text = role;
                                roleText.color = Color.white;
                            }
                            if (child.name == "Location")
                            {
                                locationText = child.GetComponent<Text>();
                                locationText.text = location;
                                locationText.color = Color.white;
                            }

                            if (child.name.Contains("FireComplex"))
                            {
                                GameObject fire = child.gameObject;
                                if (status.Contains("4"))
                                {
                                    fire.SetActive(true);
                                }
                                else
                                {
                                    fire.SetActive(false);
                                }
                            }
                            if (child.name.Contains("ServerSmoke"))
                            {
                                GameObject smoke = child.gameObject;
                                if (status.Contains("3"))
                                {
                                    smoke.SetActive(true);
                                }
                                else
                                {
                                    smoke.SetActive(false);
                                }
                            }
                            if (child.name.Contains("Flare"))
                            {
                                GameObject flare = child.gameObject;
                                if (status.Contains("2"))
                                {
                                    flare.SetActive(true);
                                }
                                else
                                {
                                    flare.SetActive(false);
                                }
                            }
                        }
                    }
                    else
                    {
                        int count = 0;
                        foreach (GameObject instance in instances)
                        {
                            Transform[] allChildren = instance.GetComponentsInChildren<Transform>();
                            foreach (Transform child in allChildren)
                            {
                                if (child.name == "Name")
                                {
                                    nameText = child.GetComponent<Text>();

                                    if (nameText.text == name)
                                    {
                                        instanceList[count].description = description;

                                        GameObject fire = instance.transform.Find("FireComplex").gameObject;
                                        GameObject smoke = instance.transform.Find("ServerSmoke").gameObject;
                                        GameObject flare = instance.transform.Find("Flare").gameObject;

                                        if (type != "2")
                                        {
                                            instance.transform.position = new Vector3(int.Parse(x), yPos, int.Parse(z));
                                        }
                                        else
                                        {
                                            float type2yPos = 3.3F;
                                            instance.transform.position = new Vector3(int.Parse(x), type2yPos, int.Parse(z));
                                        }

                                        instance.transform.Rotate(new Vector3(0, int.Parse(rotation), 0));

                                        if (status.Contains("4"))
                                        {
                                            fire.SetActive(true);
                                            nameText.color = Color.red;
                                        }
                                        else if (status.Contains("3"))
                                        {
                                            flare.SetActive(false);
                                            fire.SetActive(false);
                                            smoke.SetActive(true);

                                            Color color = new Color();
                                            ColorUtility.TryParseHtmlString("#FF8F18FF", out color);
                                            nameText.color = color;
                                        }
                                        else if (status.Contains("2"))
                                        {
                                            fire.SetActive(false);
                                            smoke.SetActive(false);

                                            flare.SetActive(true);
                                            nameText.color = Color.yellow;
                                        }
                                        else if (status.Contains("1"))
                                        {
                                            flare.SetActive(false);
                                            fire.SetActive(false);
                                            smoke.SetActive(false);
                                            nameText.color = Color.blue;
                                        }
                                        else if (status.Contains("0"))
                                        {
                                            flare.SetActive(false);
                                            fire.SetActive(false);
                                            smoke.SetActive(false);
                                            nameText.color = Color.green;
                                        }
                                        GameObject canvas = instance.transform.Find("Canvas").gameObject;

                                        GameObject roleObject = canvas.transform.Find("Role").gameObject;
                                        roleText = roleObject.GetComponent<Text>();
                                        roleText.text = role;

                                        GameObject locationObject = canvas.transform.Find("Location").gameObject;
                                        locationText = locationObject.GetComponent<Text>();
                                        locationText.text = location;

                                        break;
                                    }
                                }

                            }
                            count++;
                        }

                    }
                }
                if (command == "SITE_1.0")
                {
                    string x = data[1];
                    string z = data[2];
                    string width = data[3];
                    string height = data[4];
                    string rotation = data[5];
                    string name = data[6];
                    string location = data[7];
                    string description = data[8];

                    SiteInstanceData siteInstanceData = new SiteInstanceData();
                    siteInstanceData.description = description;
                    siteInstanceData.name = name;

                    //Debug.LogFormat("Command {0} {1} {2} {3} {4} {5} {6} {7} {8}", command, name, x, z, width, height, rotation, status, description);

                    bool found = false;

                    foreach (SiteInstanceData siteInstance in siteInstanceList)
                    {
                        if (siteInstance.name == name)
                        {
                            siteInstance.instance.transform.Rotate(new Vector3(0, int.Parse(rotation), 0));
                            siteInstance.instance.transform.localScale = new Vector3(float.Parse(width), 1, float.Parse(height));
                            siteInstance.instance.transform.position = new Vector3(int.Parse(x), yPos, int.Parse(z));

                            Transform[] allChildren = siteInstance.canvas.GetComponentsInChildren<Transform>();
                            foreach (Transform child in allChildren)
                            {
                                if (child.name == "Name")
                                {
                                    Text textname = child.GetComponent<Text>();
                                    textname.text = name;
                                    textname.color = Color.white;

                                }
                                if (child.name == "Location")
                                {
                                    Text textname = child.GetComponent<Text>();
                                    textname.text = location;
                                    textname.color = Color.white;
                                }
                            }
                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        siteInstanceData.instance = (GameObject)Instantiate(sitePrefab, new Vector3(int.Parse(x), yPos, int.Parse(z)), new Quaternion(0, 0, 0, 0));
                        siteInstanceData.instance.transform.Rotate(new Vector3(0, int.Parse(rotation), 0));
                        siteInstanceData.instance.transform.localScale = new Vector3(float.Parse(width), 1, float.Parse(height));

                        Renderer renderer = siteInstanceData.instance.GetComponent<Renderer>();

                        siteInstanceData.canvas = (GameObject)Instantiate(canvasPrefab, siteInstanceData.instance.transform.position, new Quaternion(0, 0, 0, 0));
                        //Renderer canvasRen = siteInstanceData.canvas.GetComponent<Renderer>();

                        siteInstanceData.canvas.transform.SetParent(siteInstanceData.instance.transform, true);
                        siteInstanceData.canvas.transform.position = new Vector3(renderer.bounds.center.x - renderer.bounds.size.x / 3f, renderer.bounds.center.y, renderer.bounds.center.z);
                        siteInstanceList.Add(siteInstanceData);

                        Transform[] allChildren = siteInstanceData.canvas.GetComponentsInChildren<Transform>();
                        foreach (Transform child in allChildren)
                        {
                            if (child.name == "Name")
                            {
                                Text textname = child.GetComponent<Text>();
                                textname.text = name;
                                textname.color = Color.white;

                            }
                            if (child.name == "Location")
                            {
                                Text textname = child.GetComponent<Text>();
                                textname.text = location;
                                textname.color = Color.white;
                            }
                        }

                    }
                }
            }
        }
        if (commands.Count > 0)
        {
            commands.Clear();
        }
    }
コード例 #43
0
 public void AddAsObjectTest()
 {
     InstanceData instance = new InstanceData();
     instance.Name = "MyName";
     instances.Add((Object)instance);
 }
コード例 #44
0
 public void AddItemTest()
 {
     InstanceData instance = new InstanceData();
     instance.Name = "MyName";
     instances[instance.Name] = instance;
 }
コード例 #45
0
    private Mesh BuildBuffers(InstanceData[] instances, Mesh existingMesh)
    {
        if (meshFilter)
        {
            Mesh mesh;

            if (existingMesh == null)
            {
                mesh = BakeMesh(instances);
            }
            else
            {
                mesh = existingMesh;
            }

            generated = new GameObject("Generated");
            generated.transform.SetParent(transform, false);
            generated.transform.localScale = defaultLocalScale;
            var filter = generated.AddComponent<MeshFilter>();

            filter.sharedMesh = mesh;

            var renderer = generated.AddComponent<MeshRenderer>();
            renderer.sharedMaterial = instancingMaterial;

            generated.AddComponent<NoAutomaticFade>();

            return mesh;
        }
        else
        {
            return null;
        }
    }
コード例 #46
0
ファイル: Util.cs プロジェクト: CompHound/CompHoundInv
        /// <summary>
        /// PUT JSON document data into 
        /// the specified mongoDB collection.
        /// </summary>
        public static bool Put(
            string collection_name_and_id,
            InstanceData data,
            out string result)
        {
            var client = new RestClient( RestApiBaseUrl );

              var request = new RestRequest( _api_version + "/"
            + collection_name_and_id, Method.PUT );

              request.RequestFormat = DataFormat.Json;

              // Check what we actually send.
              //Debug.Print( request.JsonSerializer.Serialize( data ) );

              request.AddBody( data ); // uses JsonSerializer

              // Didn't work for me
              //request.AddObject( data ); // http://matthewschrager.com/2013/02/19/restsharp-post-body/

              // POST params instead of body is more efficient
              // since there's no serialization to JSON.
              // But our data is a bit large for that.
              //request.AddParameter("A", "foo");
              //request.AddParameter("B", "bar");

              IRestResponse response = client.Execute( request );

              bool rc = System.Net.HttpStatusCode.Accepted
            == response.StatusCode;

              if( rc )
              {
            result = response.Content; // raw content as string
              }
              else
              {
            //if( response.ErrorMessage.Equals(
            //  "Unable to connect to the remote server" ) )
            //  "does the database exist at all?"

            result = response.ErrorMessage;

            Debug.Print( "HTTP PUT error: " + result );
              }
              return rc;
        }
コード例 #47
0
	void LoadData () {

		// Load locally saved gameplay data
		string data = DataManager.LoadJsonData (GetFilename ());
		instance = JsonReader.Deserialize<InstanceData> (data);
	}
コード例 #48
0
ファイル: SampleInfo1.cs プロジェクト: shizhexu/opensplice
	    private void initialiseInstanceData ()
	    {
	        for ( int i = 0; i < MAX_INSTANCE; i++ ) {
	            instanceDataList[i] = new InstanceData();
	            instanceDataList[i].instanceState = InstanceStateKind.Alive;
	            instanceDataList[i].viewState = ViewStateKind.New;
	            instanceDataList[i].DisposedGenerationCount = 0;
	            instanceDataList[i].NoWritersGenerationCount = 0;
	            instanceDataList[i].samples = new LinkedList<SampleData>();
	            instanceDataList[i].expected = null;
	            instanceDataList[i].numSamples = 0;
	        }
	    } 
コード例 #49
0
 public void EnumeratorTest()
 {
     InstanceData instance = new InstanceData();
     instance.Name = "MyName";
     instances.Add(instance);
     IEnumerator enumerator = instances.GetEnumerator();
     enumerator.Reset();
     while (enumerator.MoveNext())
     {
         Assert.IsNotNull(enumerator.Current);
     }
 }
コード例 #50
0
	public void Reset () {
		instance = null;
	}
コード例 #51
0
 public void Init()
 {
     XmlTextReader xmlReader = new XmlTextReader(new StringReader(xmlString));
     XmlSerializer xmlSerializer = new XmlSerializer(typeof(InstanceData));
     instance = xmlSerializer.Deserialize(xmlReader) as InstanceData;
 }
コード例 #52
0
    public override void OnEnable()
    {
        base.OnEnable();
        if (m_mesh == null) return;

        if (m_data_transfer_mode == DataTransferMode.Buffer && !SystemInfo.supportsComputeShaders)
        {
            Debug.Log("BatchRenderer: ComputeBuffer is not available. fallback to Texture data transfer mode.");
            m_data_transfer_mode = DataTransferMode.Texture;
        }
        if (m_data_transfer_mode == DataTransferMode.TextureWithPlugin && !BatchRendererUtil.IsCopyToTextureAvailable())
        {
            Debug.Log("BatchRenderer: CopyToTexture plugin is not available. fallback to Texture data transfer mode.");
            m_data_transfer_mode = DataTransferMode.Texture;
        }

        m_instance_data = new InstanceData();
        if (m_data_transfer_mode == DataTransferMode.Buffer)
        {
            m_instance_buffer = new InstanceBuffer();
        }
        else
        {
            m_instance_texture = new InstanceTexture();
        }

        ResetGPUData();
    }
コード例 #53
0
	void Setup () {

		// Create new instance data
		instance = new InstanceData ();

		try {
			// Assign the deck
			instance.DeckName = Game.Decks.Deck.Name;
		} catch {
			throw new System.Exception ("Failed to setup game controller because a deck has not been chosen.");
		}

		try {
			// Assign the players
			instance.Players = Game.Manager.Players.Values.ToArray ();
		} catch {
			throw new System.Exception ("Failed to setup game controller because the players have not been set.");
		}

		PopulateData ();
		SendData ();
		SaveData ();
	}
コード例 #54
0
	void LoadInstanceData (NetMessage msg) {

		// Peers receive the data from the host and deserialize it
		if (!Hosting) {
			instance = JsonReader.Deserialize<InstanceData> (msg.str1);
			SaveData ();
		}
	}
コード例 #55
0
    public override void OnEnable()
    {
        base.OnEnable();
        if (m_mesh == null) return;

        m_instance_data = new InstanceData();

        ReleaseGPUData();
        if (m_data_transfer_mode == DataTransferMode.Buffer)
        {
            m_instance_buffer = new InstanceBuffer();
        }
        else
        {
            m_instance_texture = new InstanceTexture();
            if (m_data_transfer_mode == DataTransferMode.TextureWithMesh)
            {
                m_data_transfer_mesh = BatchRendererUtil.CreateDataTransferMesh(m_max_instances);
            }
        }

        ResetGPUData();
    }