• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Instance类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Instance的典型用法代码示例。如果您正苦于以下问题:C# Instance类的具体用法?C# Instance怎么用?C# Instance使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Instance类属于命名空间,在下文中一共展示了Instance类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetAppliedMigrations

 public DBAppliedMigration[] GetAppliedMigrations(Instance instance)
 {
     List<DBAppliedMigration> result = new List<DBAppliedMigration>();
     using (SqlConnection connection = new SqlConnection(connectionStringProvider.GetConnectionString(instance)))
     {
         connection.Open();
         using (SqlCommand cmd = new SqlCommand(@"SELECT [Id]
                                                       ,[Executed_at]
                                                       ,[Executed_by]
                                                       ,[MigrateScript]
                                                       ,[RollbackScript]
                                                       ,[Migration_id]
                                                   FROM [DBAppliedMigrations]
                                                   ORDER BY [Executed_at] DESC", connection))
         {
             using (SqlDataReader reader = cmd.ExecuteReader())
             {
                 while (reader.Read())
                 {
                     DBAppliedMigration appliedMig = new DBAppliedMigration();
                     appliedMig.Id = reader.GetInt32(0);
                     appliedMig.At = reader.GetDateTime(1);
                     appliedMig.By = reader.GetString(2);
                     appliedMig.MigrateScript = reader.GetString(3);
                     appliedMig.RollbackScript = reader.GetString(4);
                     appliedMig.MigrationId = reader.GetInt32(5);
                     result.Add(appliedMig);
                 }
             }
         }
     }
     return result.ToArray();
 }
开发者ID:julienblin,项目名称:Colibri,代码行数:33,代码来源:SqlServerDBMigrationTablesManager.cs


示例2: classProb

		/// <summary> Gets class probability for instance.
		/// 
		/// </summary>
		/// <exception cref="Exception">if something goes wrong
		/// </exception>
		public virtual double classProb(int classIndex, Instance instance, int theSubset)
		{
			
			if (theSubset > - 1)
			{
				return m_distribution.prob(classIndex, theSubset);
			}
			else
			{
				double[] weights = GetWeights(instance);
				if (weights == null)
				{
					return m_distribution.prob(classIndex);
				}
				else
				{
					double prob = 0;
					for (int i = 0; i < weights.Length; i++)
					{
						prob += weights[i] * m_distribution.prob(classIndex, i);
					}
					return prob;
				}
			}
		}
开发者ID:intille,项目名称:mitessoftware,代码行数:30,代码来源:ClassifierSplitModel.cs


示例3: Run

		public static void Run () {
			var model = new StateMachine<Instance>("history");

			var initial = new PseudoState<Instance>("initial", model, PseudoStateKind.Initial);
			var shallow = new State<Instance>("shallow", model);
			var deep = new State<Instance>("deep", model);
			var end = new FinalState<Instance>("final", model);

			var s1 = new State<Instance>("s1", shallow);
			var s2 = new State<Instance>("s2", shallow);

			initial.To(shallow);
			new PseudoState<Instance>("shallow", shallow, PseudoStateKind.ShallowHistory).To(s1);
			s1.To(s2).When<string>(c => c == "move");
			shallow.To(deep).When<string>(c => c == "go deep");
			deep.To(shallow).When<string>(c => c == "go shallow");
			s2.To(end).When<string>(c => c == "end");

			model.Validate();

			var instance = new Instance("history");

			model.Initialise(instance);

			model.Evaluate(instance, "move");
			model.Evaluate(instance, "go deep");
			model.Evaluate(instance, "go shallow");
			model.Evaluate(instance, "end");

			Trace.Assert(model.IsComplete(instance));
		}
开发者ID:steelbreeze,项目名称:state.cs,代码行数:31,代码来源:History.cs


示例4: ConsoleForm

        public ConsoleForm(Instance inst)
        {
            this.inst = inst;
            Text = inst.Name + " is running...";

            InitializeComponent();

            if (inst.InstProcess != null)
            {
                Message("Instance started with command: " + inst.InstProcess.StartInfo.FileName +
                     " " + inst.InstProcess.StartInfo.Arguments.ToString());

                inst.InstQuit += new EventHandler<InstQuitEventArgs>(InstQuit);

                inst.InstProcess.OutputDataReceived += new DataReceivedEventHandler(InstOutput);
                inst.InstProcess.ErrorDataReceived += new DataReceivedEventHandler(InstOutput);

                inst.InstProcess.BeginOutputReadLine();
                inst.InstProcess.BeginErrorReadLine();
            }

            trayIcon.Visible = true;

            trayIcon.DoubleClick += (o, args) => ShowConsole = !ShowConsole;
            showConsoleToolStripMenuItem.Checked = ShowConsole;
        }
开发者ID:Tom-V,项目名称:MultiMC,代码行数:26,代码来源:ConsoleForm.cs


示例5: Compute

        public static unsafe bool Compute( Instance instance, double* points, int pointCount, int* triangles,
			int triangleCount, int maxTrianglesInDecimatedMesh, int maxVerticesPerConvexHull )
        {
            bool result = HACD_Compute( instance.nativeObject, points, pointCount, triangles, triangleCount,
                maxTrianglesInDecimatedMesh, maxVerticesPerConvexHull );
            return result;
        }
开发者ID:whztt07,项目名称:SDK,代码行数:7,代码来源:HACDWrapper.cs


示例6: EncoreClient

 public EncoreClient()
 {
     encoreClient = new Utilities();
     encoreInstance = new Instance();
     encoreLogDetail = new LogDetail();
     encoreLang = new Language();
 }
开发者ID:johnernaut,项目名称:SysproUtils,代码行数:7,代码来源:EncoreClient.cs


示例7: InstanceSerialiseDeserialise

        public void InstanceSerialiseDeserialise()
        {
            var originalInstance = new Instance()
            {
                Key = Guid.NewGuid(),
                GroupKey = Guid.NewGuid(),
                TargetKey = Guid.NewGuid(),
                Name = "Test Instance",
                Tags = new Dictionary<string, string>()
                {
                    { "tagKey", "Some tag value." },
                    { "secondKey", "Multiline \r\n   test!" }
                }
            };

            Instance secondInstance;
            using (var stream = originalInstance.Serialise())
            {
                secondInstance = new Instance(stream);
            }

            Assert.AreEqual(originalInstance.Key, secondInstance.Key);
            Assert.AreEqual(originalInstance.GroupKey, secondInstance.GroupKey);
            Assert.AreEqual(originalInstance.TargetKey, secondInstance.TargetKey);
            Assert.AreEqual(originalInstance.Name, secondInstance.Name);

            Assert.IsNotNull(secondInstance.Tags);
            foreach (var tag in originalInstance.Tags)
            {
                Assert.IsTrue(secondInstance.Tags.ContainsKey(tag.Key));
                Assert.AreEqual(tag.Value, secondInstance.Tags[tag.Key]);
            }
        }
开发者ID:danielrbradley,项目名称:Plywood,代码行数:33,代码来源:InstanceTests.cs


示例8: Register

 private void Register()
 {
     try
     {
         if (!config.InstanceKey.HasValue || reregister)
         {
             try
             {
                 var instances = new Instances(config);
                 Instance instance = new Instance() { TargetKey = config.TargetKey };
                 instances.CreateInstance(instance);
                 config.InstanceKey = instance.Key;
             }
             catch (Exception ex)
             {
                 throw new DeploymentException("Failed registering instance.", ex);
             }
             try
             {
                 Utils.Registry.Save(config);
             }
             catch (Exception ex)
             {
                 throw new DeploymentException("Failed updating config after instance registration.", ex);
             }
         }
     }
     catch (Exception ex)
     {
         this.EventLog.WriteEntry("Failed service registration: " + ex.ToString(), EventLogEntryType.Error);
         throw;
     }
     reregister = false;
 }
开发者ID:danielrbradley,项目名称:Plywood,代码行数:34,代码来源:PlywoodPullService.cs


示例9: Run

		public static void Run () {
			var model = new StateMachine<Instance>("model");

			var initial = new PseudoState<Instance>("initial", model);

			var choice = new PseudoState<Instance>("choice", model, PseudoStateKind.Choice);
			var junction = new PseudoState<Instance>("junction", model, PseudoStateKind.Junction);

			var finalState = new FinalState<Instance>("final", model);

			initial.To(choice);
			choice.To(junction).When(i => i.Int1 == 0).Effect(i => i.Int1 = 1);
			choice.To(finalState).Else();
			junction.To(choice).When(i => i.Int2 == 0).Effect(i => i.Int2 = 2);

			model.Validate();

			var instance = new Instance("else");

			model.Initialise(instance);

			Trace.Assert(model.IsComplete(instance));
			Trace.Assert(instance.Int1 == 1);
			Trace.Assert(instance.Int2 == 2);
		}
开发者ID:steelbreeze,项目名称:state.cs,代码行数:25,代码来源:Else.cs


示例10: Create

        public IInstance Create(Configuration.ISettings configurationSettings)
        {
            Instance instance = new Instance(configurationSettings, _connectionFactory, _messageSerializer);
            instance.Connect();

            return instance;
        }
开发者ID:Zananok,项目名称:Harmonize,代码行数:7,代码来源:Factory.cs


示例11: Run

		public static void Run () {

			var model = new StateMachine<Instance>("model");
			var initial = new PseudoState<Instance>("initial", model, PseudoStateKind.Initial);
			var junction1 = new PseudoState<Instance>("junction1", model, PseudoStateKind.Junction);
			var junction2 = new PseudoState<Instance>("junction2", model, PseudoStateKind.Junction);

			var pass = new State<Instance>("success", model);
			var fail = new State<Instance>("error", model);

			initial.To(junction1);

			junction1.To(junction2).When(i => i.Int1 == 0).Effect(i => i.Int1++);
			junction1.To(fail).Else();
			junction2.To(pass).When(i => i.Int1 == 0).Effect(i => i.Int1++);
			junction2.To(fail).Else();

			model.Validate();

			var instance = new Instance("static");

			model.Initialise(instance);

			Trace.Assert(pass == instance.GetCurrent(model.DefaultRegion));

			Trace.Assert(2 == instance.Int1);
		}
开发者ID:steelbreeze,项目名称:state.cs,代码行数:27,代码来源:Static.cs


示例12: TestInstance

        public static void TestInstance(Assert assert)
        {
            assert.Expect(17);

            var i = new Instance();

            assert.Ok(i != null, "i created");
            assert.Equal(i.Foo(1), "Foo(int x)", "Instance Foo(int x)");
            assert.Equal(i.Foo("string"), "Foo(string s)", "Instance Foo(string s)");
            assert.Equal(i.Foo(1.1), "Foo(double d)", "Instance Foo(double d)");
            assert.Equal(i.Foo(1, 2), "Foo(int x, int y)", "Instance Foo(int x, int y)");
            assert.Equal(i.Foo(1, 1.1), "Foo(int x, double y)", "Instance Foo(int x, double y)");
            assert.Equal(i.Foo(1.1, 1), "Foo(double x, int y)", "Instance Foo(double x, int y)");

            assert.Equal(i.FooReturnType(1), 'C', "Instance char FooReturnType(int y)");
            assert.Equal(i.FooReturnType(1.1), "string FooReturnType(double d)", "Instance string FooReturnType(double d)");

            assert.Equal(i.FooOptionalParameters(1), "FooOptionalParameters(int x)", "Instance FooOptionalParameters(int x)");
            assert.Equal(i.FooOptionalParameters(1, 2), "FooOptionalParameters(int x, int y = 5)", "Instance FooOptionalParameters(int x, int y = 5)");

            assert.Equal(i.FooMultipleOptionalParameters(1, 2), "FooMultipleOptionalParameters(int x, int y = 5)", "Instance FooMultipleOptionalParameters(int x, int y = 5)");
            assert.Equal(i.FooMultipleOptionalParameters(1, z: 2), "FooMultipleOptionalParameters(int x, int y = 5, int z = 10)", "Instance FooMultipleOptionalParameters(int x, int y = 5, int z = 10)");
            assert.Equal(i.FooMultipleOptionalParameters(1, 2, 3), "FooMultipleOptionalParameters(int x, int y = 5, int z = 10)", "Instance FooMultipleOptionalParameters(int x, int y = 5, int z = 10)");
            assert.Equal(i.FooMultipleOptionalParameters(1, z: 2, y: 3), "FooMultipleOptionalParameters(int x, int y = 5, int z = 10)", "Instance FooMultipleOptionalParameters(int x, int y = 5, int z = 10)");

            assert.Equal(i.FooNamedArgument(x: 1), "FooNamedArgument(int x)", "Static FooNamedArgument(int x)");
            assert.Equal(i.FooNamedArgument(d: 1), "FooNamedArgument(double d)", "Static FooNamedArgument(double d)");
        }
开发者ID:txdv,项目名称:Testing,代码行数:28,代码来源:TestOverloadInstanceMethods.cs


示例13: Run

		public static void Run () {
			var model = new StateMachine<Instance>("compTest");
			var initial = new PseudoState<Instance>("initial", model, PseudoStateKind.Initial);

			var activity1 = new State<Instance>("activity1", model);
			var activity2 = new State<Instance>("activity2", model);
			var activity3 = new State<Instance>("activity3", model);
			var junction1 = new PseudoState<Instance>("junction1", model, PseudoStateKind.Junction);
			var junction2 = new PseudoState<Instance>("junction2", model, PseudoStateKind.Junction);
			var end = new FinalState<Instance>("end", model);

			var subInitial = new PseudoState<Instance>("subInitial", activity2, PseudoStateKind.Initial);
			var subEnd = new FinalState<Instance>("subEnd", activity2);

			subInitial.To(subEnd);
			initial.To(activity1);
			activity1.To(activity2);
			activity2.To(junction1);
			junction1.To(junction2).Else();
			junction2.To(activity3).Else();
			activity3.To(end);

			model.Validate();

			var instance = new Instance("transitions");
			model.Initialise(instance);

			Trace.Assert(model.IsComplete(instance));
		}
开发者ID:steelbreeze,项目名称:state.cs,代码行数:29,代码来源:Transitions.cs


示例14: GceInstanceViewModel

        public GceInstanceViewModel(GceSourceRootViewModel owner, Instance instance)
        {
            _owner = owner;
            Instance = instance;

            UpdateInstanceState();
        }
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-visualstudio,代码行数:7,代码来源:GceInstanceViewModel.cs


示例15: Run

		public static void Run () {
			var model = new StateMachine<Instance>("model");
			var initial = new PseudoState<Instance>("initial", model, PseudoStateKind.Initial);
			var target = new State<Instance>("state", model).Entry(i => i.Int1++).Exit(i => i.Int2++);

			initial.To(target);

			target.To().When<string>(m => m == "internal").Effect(i => i.Int3++);
			target.To(target).When<string>(m => m == "external").Effect(i => i.Int3++);

			var instance = new Instance("internal");

			model.Validate();

			model.Initialise(instance);

			model.Evaluate(instance, "internal");

			Trace.Assert(target == instance.GetCurrent(model.DefaultRegion));
			Trace.Assert(1 == instance.Int1);
			Trace.Assert(0 == instance.Int2);
			Trace.Assert(1 == instance.Int3);

			model.Evaluate(instance, "external");

			Trace.Assert(target == instance.GetCurrent(model.DefaultRegion));
			Trace.Assert(2 == instance.Int1);
			Trace.Assert(1 == instance.Int2);
			Trace.Assert(2 == instance.Int3);
		}
开发者ID:steelbreeze,项目名称:state.cs,代码行数:30,代码来源:Internal.cs


示例16: ActivateHoverTooltip

    public void ActivateHoverTooltip(Instance currentInstnace)
    {
        this.instance = currentInstnace;
        ConstructTooltipDataString();

        hoverTooltip.SetActive(true);
    }
开发者ID:CobaltBlack,项目名称:Project-Hex,代码行数:7,代码来源:NodeTooltip.cs


示例17: GetCredentialsForInstance

        /// <summary>
        /// Loads the list of Windows credentials associated with <paramref name="instance"/>.
        /// </summary>
        /// <param name="instance">The GCE VM</param>
        /// <returns>The list of <seealso cref="WindowsInstanceCredentials"/> associated with The GCE VM. It might be
        /// empty if no credentials are found.</returns>
        public IEnumerable<WindowsInstanceCredentials> GetCredentialsForInstance(Instance instance)
        {
            var instancePath = GetInstancePath(instance);
            IEnumerable<WindowsInstanceCredentials> result;
            if (_credentialsForInstance.TryGetValue(instancePath, out result))
            {
                return result;
            }

            var instanceStoragePath = GetStoragePathForInstance(instance);
            if (!Directory.Exists(instanceStoragePath))
            {
                result = Enumerable.Empty<WindowsInstanceCredentials>();
            }
            else
            {
                result = Directory.EnumerateFiles(instanceStoragePath)
                    .Where(x => Path.GetExtension(x) == PasswordFileExtension)
                    .Select(x => LoadEncryptedCredentials(x))
                    .OrderBy(x => x.User);
            }
            _credentialsForInstance[instancePath] = result;

            return result;
        }
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-visualstudio,代码行数:31,代码来源:WindowsCredentialsStore.cs


示例18: SaveInstance

        public int SaveInstance(IInstanceDb instanceDb, int? transactionNumber = null)
        {
            if (instanceDb.InstanceId != _instanceId)
                throw new Exception("Attempt to save Instance with wrong InstanceId");

            Instance record;
            var recordOld = new Instance();
            if (instanceDb.InstanceId == 0)
            {
                record = new Instance();
                Context.AddToInstances(record);
            }
            else
            {
                record = Context.Instances.Where(r => r.InstanceId == instanceDb.InstanceId).First();
                ReflectionHelper.CopyAllProperties(record, recordOld);
            }

            record.InstanceName = instanceDb.InstanceName;

            Context.SaveChanges();
            if (instanceDb.InstanceId == 0)
            {
                instanceDb.InstanceId = record.InstanceId;
                LogToDb(UserId, "Instances", record.InstanceId, "I", XmlHelper.GetObjectXml(record), transactionNumber);
            }
            else
            {
                LogToDb(UserId, "Instances", record.InstanceId, "U", XmlHelper.GetDifferenceXml(recordOld, record), transactionNumber);
            }

            return instanceDb.InstanceId;
        }
开发者ID:urise,项目名称:JohanCorner,代码行数:33,代码来源:InstanceRepository.cs


示例19: AddRef

 /// <summary>
 /// Create and remember a reference to an Instance.
 /// </summary>
 /// <param name="instance"></param>
 /// <param name="station">station to which this instance belongs</param>
 /// <returns>new instance reference</returns>
 public InstanceRef AddRef(Instance instance, Station station)
 {
     long id = NextId();
     InstanceRef iRef = new InstanceRefImpl(id, instance, station);
     refs.Add(id, iRef);
     return iRef;
 }
开发者ID:jblindberg,项目名称:Clouseau,代码行数:13,代码来源:InstanceMemory.cs


示例20: SparseInstance

		/// <summary> Constructor that generates a sparse instance from the given
		/// instance. Reference to the dataset is set to null.
		/// (ie. the instance doesn't have access to information about the
		/// attribute types)
		/// 
		/// </summary>
		/// <param name="instance">the instance from which the attribute values
		/// and the weight are to be copied
		/// </param>
		public SparseInstance(Instance instance)
		{
			
			m_Weight = instance.m_Weight;
			m_Dataset = null;
			m_NumAttributes = instance.numAttributes();
			if (instance is SparseInstance)
			{
				m_AttValues = ((SparseInstance) instance).m_AttValues;
				m_Indices = ((SparseInstance) instance).m_Indices;
			}
			else
			{
				double[] tempValues = new double[instance.numAttributes()];
				int[] tempIndices = new int[instance.numAttributes()];
				int vals = 0;
				for (int i = 0; i < instance.numAttributes(); i++)
				{
					if (instance.value_Renamed(i) != 0)
					{
						tempValues[vals] = instance.value_Renamed(i);
						tempIndices[vals] = i;
						vals++;
					}
				}
				m_AttValues = new double[vals];
				m_Indices = new int[vals];
				Array.Copy(tempValues, 0, m_AttValues, 0, vals);
				Array.Copy(tempIndices, 0, m_Indices, 0, vals);
			}
		}
开发者ID:intille,项目名称:mitessoftware,代码行数:40,代码来源:SparseInstance.cs



注:本文中的Instance类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# InstanceContext类代码示例发布时间:2022-05-24
下一篇:
C# InstallWalker类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap