/// <summary> /// Generics sample /// </summary> private void workWithGenerics( ) { GenericSample <int> intSample = new GenericSample <int>(); GenericSample <string> strSample = new GenericSample <string>(); int oneInt = 55; string oneStr = "Hello"; intSample.Data = 55; strSample.Data = "Potato"; tbTopLeft.Text = $"{oneInt} and {intSample.Data} are {intSample.IsSameTo(oneInt)}\n"; tbTopLeft.Text += $"{oneStr} and {strSample.Data} are {strSample.IsSameTo(oneStr)}\n"; int first = 6; string second = "16"; byte third = 32; short forth = 86; long fifth = 985; double sixth = 54.12; tbTopRight.Text = $"Square of {first,-8} is {SimpleMath.Square<int>(first):N0}\n" + $"Square of {second,-8} is {SimpleMath.Square<string>(second):N0}\n" + $"Square of {third,-8} is {SimpleMath.Square<byte>(third):N0}\n" + $"Square of {forth,-8} is {SimpleMath.Square<short>(forth):N0}\n" + $"Square of {fifth,-8} is {SimpleMath.Square<long>(fifth):N0}\n" + $"Square of {sixth,-8} is {SimpleMath.Square<double>(sixth):N2}\n"; }
public void FailingTest() { GenericSample testGenericSample = new GenericSample(); Assert.Equal(5, testGenericSample.Add(2, 2)); }
//[Fact] public static int Test1() { GenericSample myTestClass = new GenericSample(); int testInt = myTestClass.Add(4, 5); return(testInt); }
public void UpdateGenericSample(GenericSample theGenericSample) { try { m_GenericSamplesDictionary.Remove(theGenericSample.GenericSamples_ID); } catch { } theGenericSample.RequiresUpdate = true; m_GenericSamplesDictionary.Add(theGenericSample.GenericSamples_ID, theGenericSample); }
public void Test1() { List <int> list = new List <int>(); list.Add(5); list.Add(10); list.Add(20); GenericSample genericSample = new GenericSample(); var result = genericSample.CopyAtMost(list, 2); Debug.WriteLine(result.Count); }
static void Main(string[] args) { // int는 사용가능 Sample.Print(1); // double 형태시에 오류가 발생한다. // double형을 사용하기 위해서는 Sample class에 overloading 해주어야한다. Sample.Print(1.123); // 하지만 Generic 타입으로 선언한 함수의 경우 데이터타입을 자유롭게 넣어줄수있다. GenericSample.Print(1); GenericSample.Print(1.123); GenericSample.Print("test"); GenericSample.Print(1.2345f); }
public string NewGenericSample(string StationID, string Label, int PlotAtScale, double LocationConfidenceMeters, string Notes, string DataSourceID, string RuleID, IPoint Shape) { GenericSample newGenericSample = new GenericSample(); sysInfo SysInfoTable = new sysInfo(m_theWorkspace); newGenericSample.GenericSamples_ID = SysInfoTable.ProjAbbr + ".GenericSamples." + SysInfoTable.GetNextIdValue("GenericSamples"); newGenericSample.FieldID = StationID; newGenericSample.Label = Label; newGenericSample.PlotAtScale = PlotAtScale; newGenericSample.LocationConfidenceMeters = LocationConfidenceMeters; newGenericSample.Notes = Notes; newGenericSample.RuleID = RuleID; newGenericSample.DataSourceID = DataSourceID; newGenericSample.Shape = Shape; newGenericSample.RequiresUpdate = false; m_GenericSamplesDictionary.Add(newGenericSample.GenericSamples_ID, newGenericSample); return(newGenericSample.GenericSamples_ID); }
public void AddGenericSamples(string SqlWhereClause) { int idFld = m_GenericSamplesFC.FindField("GenericSamples_ID"); int fieldFld = m_GenericSamplesFC.FindField("FieldID"); int staFld = m_GenericSamplesFC.FindField("StationID"); int lblFld = m_GenericSamplesFC.FindField("Label"); int plotFld = m_GenericSamplesFC.FindField("PlotAtScale"); int locConfFld = m_GenericSamplesFC.FindField("LocationConfidenceMeters"); int notesFld = m_GenericSamplesFC.FindField("Notes"); int symbFld = m_GenericSamplesFC.FindField("RuleID"); int dsFld = m_GenericSamplesFC.FindField("DataSourceID"); IQueryFilter QF = new QueryFilterClass(); QF.WhereClause = SqlWhereClause; IFeatureCursor theCursor = m_GenericSamplesFC.Search(QF, false); IFeature theFeature = theCursor.NextFeature(); while (theFeature != null) { GenericSample anGenericSample = new GenericSample(); anGenericSample.GenericSamples_ID = theFeature.get_Value(idFld).ToString(); anGenericSample.FieldID = theFeature.get_Value(fieldFld).ToString(); anGenericSample.StationID = theFeature.get_Value(staFld).ToString(); anGenericSample.Label = theFeature.get_Value(lblFld).ToString(); bool result = int.TryParse(theFeature.get_Value(plotFld).ToString(), out anGenericSample.PlotAtScale); result = double.TryParse(theFeature.get_Value(locConfFld).ToString(), out anGenericSample.LocationConfidenceMeters); anGenericSample.Notes = theFeature.get_Value(notesFld).ToString(); anGenericSample.RuleID = theFeature.get_Value(symbFld).ToString(); anGenericSample.DataSourceID = theFeature.get_Value(dsFld).ToString(); anGenericSample.Shape = (IPoint)theFeature.Shape; anGenericSample.RequiresUpdate = true; m_GenericSamplesDictionary.Add(anGenericSample.GenericSamples_ID, anGenericSample); theFeature = theCursor.NextFeature(); } }
private static void Main(string[] args) { ServiceCollection serviceCollection = new ServiceCollection(); serviceCollection.AddLogging(builder => builder.AddConsole()); ServiceProvider buildServiceProvider = serviceCollection.BuildServiceProvider(); BasicSample basicSample = new BasicSample(new MyMemoryCache(new MemoryCache(new MemoryCacheOptions()), buildServiceProvider.GetRequiredService <ILogger <MyMemoryCache> >())); basicSample.Add(1, 2); basicSample.Add(1, 2); basicSample.Add(3, 4); GenericSample <int, object> genericSample = new GenericSample <int, object>( new MyMemoryCache(new MemoryCache(new MemoryCacheOptions()), buildServiceProvider.GetRequiredService <ILogger <MyMemoryCache> >())); genericSample.Add <string, Attribute>(1, 2, 3, 4); genericSample.Add <string, Attribute>(1, 2, 3, 4); genericSample.Add <string, Attribute>(5, 6, 7, 8); }
public void SaveGenericSamples() { int idFld = m_GenericSamplesFC.FindField("GenericSamples_ID"); int fieldFld = m_GenericSamplesFC.FindField("FieldID"); int staFld = m_GenericSamplesFC.FindField("StationID"); int lblFld = m_GenericSamplesFC.FindField("Label"); int plotFld = m_GenericSamplesFC.FindField("PlotAtScale"); int locConfFld = m_GenericSamplesFC.FindField("LocationConfidenceMeters"); int notesFld = m_GenericSamplesFC.FindField("Notes"); int symbFld = m_GenericSamplesFC.FindField("RuleID"); int dsFld = m_GenericSamplesFC.FindField("DataSourceID"); IEditor theEditor = ArcMap.Editor; if (theEditor.EditState == esriEditState.esriStateNotEditing) { theEditor.StartEditing(m_theWorkspace); } theEditor.StartOperation(); try { string updateWhereClause = "GenericSamples_ID = '"; IFeatureCursor insertCursor = m_GenericSamplesFC.Insert(true); foreach (KeyValuePair <string, GenericSample> aDictionaryEntry in m_GenericSamplesDictionary) { GenericSample thisGenericSample = (GenericSample)aDictionaryEntry.Value; switch (thisGenericSample.RequiresUpdate) { case true: updateWhereClause += thisGenericSample.GenericSamples_ID + "' OR GenericSamples_ID = '"; break; case false: IFeatureBuffer theFeatureBuffer = m_GenericSamplesFC.CreateFeatureBuffer(); theFeatureBuffer.set_Value(idFld, thisGenericSample.GenericSamples_ID); theFeatureBuffer.set_Value(fieldFld, thisGenericSample.FieldID); theFeatureBuffer.set_Value(staFld, thisGenericSample.StationID); theFeatureBuffer.set_Value(lblFld, thisGenericSample.Label); theFeatureBuffer.set_Value(plotFld, thisGenericSample.PlotAtScale); theFeatureBuffer.set_Value(locConfFld, thisGenericSample.LocationConfidenceMeters); theFeatureBuffer.set_Value(notesFld, thisGenericSample.Notes); theFeatureBuffer.set_Value(symbFld, thisGenericSample.RuleID); theFeatureBuffer.set_Value(dsFld, thisGenericSample.DataSourceID); theFeatureBuffer.Shape = thisGenericSample.Shape; insertCursor.InsertFeature(theFeatureBuffer); break; } } System.Runtime.InteropServices.Marshal.ReleaseComObject(insertCursor); theEditor.StopOperation("Insert GenericSamples"); theEditor.StartOperation(); updateWhereClause = updateWhereClause.Remove(updateWhereClause.Length - 32); IQueryFilter QF = new QueryFilterClass(); QF.WhereClause = updateWhereClause; IFeatureCursor updateCursor = m_GenericSamplesFC.Update(QF, false); IFeature theFeature = updateCursor.NextFeature(); while (theFeature != null) { string theID = theFeature.get_Value(idFld).ToString(); GenericSample thisGenericSample = m_GenericSamplesDictionary[theID]; theFeature.set_Value(fieldFld, thisGenericSample.FieldID); theFeature.set_Value(staFld, thisGenericSample.StationID); theFeature.set_Value(lblFld, thisGenericSample.Label); theFeature.set_Value(plotFld, thisGenericSample.PlotAtScale); theFeature.set_Value(locConfFld, thisGenericSample.LocationConfidenceMeters); theFeature.set_Value(notesFld, thisGenericSample.Notes); theFeature.set_Value(symbFld, thisGenericSample.RuleID); theFeature.set_Value(dsFld, thisGenericSample.DataSourceID); theFeature.Shape = thisGenericSample.Shape; updateCursor.UpdateFeature(theFeature); theFeature = updateCursor.NextFeature(); } theEditor.StopOperation("Update GenericSamples"); } catch { theEditor.StopOperation("GenericSamples Management Failure"); } }
public void PassingTest() { GenericSample testGenericSample = new GenericSample(); Assert.Equal(5, testGenericSample.Add(2, 3)); }
public void TestAdd(int x, int y) { GenericSample testGenericSample = new GenericSample(); Assert.Equal(5, testGenericSample.Add(x, y)); }