コード例 #1
0
ファイル: Client.cs プロジェクト: w1r2p1/cryptocurrency
        private void HandleTradeMessage(TradeEventResponse channel, dynamic data)
        {
            var raw = new JArray();

            if (data[1] is JArray)
            {
                raw = data[1];
            }
            else
            {
                var type = Convert.ToString(data[1]);

                if (type != "tu")
                {
                    return;
                }

                raw.Add(data[2]);
            }

            var pair = Exchange.DecodeSymbol(channel.Symbol);

            var symbol = SymbolFactory.Get(pair[0], pair[1]);

            var additionalData = new NameValueCollection();

            additionalData.Add("SymbolCode", symbol.Code.ToString());

            var result = Exchange.ChangeType <dynamic, TradeResult>(SymbolFactory, raw, null, additionalData);

            OnTradesReceived?.Invoke(this, new TradesReceivedEventArgs {
                Data = result
            });
        }
コード例 #2
0
 protected override Task OnToolActivateAsync(bool active)
 {
     if (_vm == null)
     {
         _vm = this.OverlayEmbeddableControl as OverlayControlViewModel;
     }
     if (_overlaySymbol == null)
     {
         QueuedTask.Run(() => {
             _overlaySymbol = SymbolFactory.ConstructPointSymbol(ColorFactory.Red, 12.0, SimpleMarkerStyle.Circle);
         });
     }
     if (_trees == null)
     {
         _trees = ActiveMapView.Map.GetLayersAsFlattenedList().FirstOrDefault((lyr) => lyr.Name == "Tree") as BasicFeatureLayer;
     }
     if (_theInspector == null)
     {
         _theInspector = new Inspector();
         var tuple = _theInspector.CreateEmbeddableControl();
         _vm.InspectorView      = tuple.Item2;
         _vm.InspectorViewModel = tuple.Item1;
     }
     return(base.OnToolActivateAsync(active));
 }
コード例 #3
0
        /// <summary>
        /// Method to override the sketch symbol after collecting the second vertex
        /// </summary>
        /// <returns>If the sketch symbology was successfully changed.</returns>
        protected override async Task <bool> OnSketchModifiedAsync()
        {
            // retrieve the current sketch geometry
            Polyline cutGeometry = await base.GetCurrentSketchAsync() as Polyline;

            await QueuedTask.Run(() =>
            {
                // if there are more than 2 vertices in the geometry
                if (cutGeometry.PointCount > 2)
                {
                    // adjust the sketch symbol
                    var symbolReference = base.SketchSymbol;
                    if (symbolReference == null)
                    {
                        var cimLineSymbol = SymbolFactory.ConstructLineSymbol(ColorFactory.RedRGB, 3,
                                                                              SimpleLineStyle.DashDotDot);
                        base.SketchSymbol = cimLineSymbol.MakeSymbolReference();
                    }
                    else
                    {
                        symbolReference.Symbol.SetColor(ColorFactory.RedRGB);
                        base.SketchSymbol = symbolReference;
                    }
                }
            });

            return(true);
        }
コード例 #4
0
        public void AssemblyVersionMustBeStrictlyCompatible()
        {
            string leftSyntax  = "[assembly: System.Reflection.AssemblyVersionAttribute(\"1.0.0.0\")]";
            string rightSyntax = "[assembly: System.Reflection.AssemblyVersionAttribute(\"2.0.0.0\")]";

            IAssemblySymbol leftSymbol  = SymbolFactory.GetAssemblyFromSyntax(leftSyntax);
            IAssemblySymbol rightSymbol = SymbolFactory.GetAssemblyFromSyntax(rightSyntax);

            Assert.Equal(new Version(1, 0, 0, 0), leftSymbol.Identity.Version);
            Assert.Equal(new Version(2, 0, 0, 0), rightSymbol.Identity.Version);

            // Compatible assembly versions
            ApiComparer differ = new();
            IEnumerable <CompatDifference> differences = differ.GetDifferences(leftSymbol, rightSymbol);

            Assert.Empty(differences);

            differ.StrictMode = true;

            // Not strictly compatible
            differences = differ.GetDifferences(leftSymbol, rightSymbol);
            Assert.Single(differences);

            CompatDifference expected = new(DiagnosticIds.AssemblyIdentityMustMatch, string.Empty, DifferenceType.Changed, $"{leftSymbol.Name}, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");

            Assert.Equal(expected, differences.First());
        }
コード例 #5
0
        public void RetargetableFlagSet(bool strictMode)
        {
            string syntax = @"
using System.Reflection;

[assembly: AssemblyFlags(AssemblyNameFlags.Retargetable)]
";

            // Emitting the assembly to a physical location to workaround:
            // https://github.com/dotnet/roslyn/issues/54836
            string leftAssembly  = SymbolFactory.EmitAssemblyFromSyntax(syntax, publicKey: _publicKey);
            string rightAssembly = SymbolFactory.EmitAssemblyFromSyntax(syntax);

            IAssemblySymbol leftSymbol  = new AssemblySymbolLoader().LoadAssembly(leftAssembly);
            IAssemblySymbol rightSymbol = new AssemblySymbolLoader().LoadAssembly(rightAssembly);

            Assert.True(leftSymbol.Identity.IsRetargetable);
            Assert.True(rightSymbol.Identity.IsRetargetable);
            Assert.False(rightSymbol.Identity.HasPublicKey);
            Assert.Equal(_publicKey, leftSymbol.Identity.PublicKey);

            ApiComparer differ = new();

            differ.StrictMode = strictMode;

            Assert.Empty(differ.GetDifferences(leftSymbol, rightSymbol));
        }
コード例 #6
0
        public void LeftAssemblyKeyTokenNull(bool strictMode)
        {
            string syntax = "namespace EmptyNs { }";

            IAssemblySymbol leftSymbol  = SymbolFactory.GetAssemblyFromSyntax(syntax);
            IAssemblySymbol rightSymbol = SymbolFactory.GetAssemblyFromSyntax(syntax, publicKey: _publicKey);

            Assert.False(leftSymbol.Identity.HasPublicKey);
            Assert.Equal(_publicKey, rightSymbol.Identity.PublicKey);

            ApiComparer differ = new();

            differ.StrictMode = strictMode;
            IEnumerable <CompatDifference> differences = differ.GetDifferences(leftSymbol, rightSymbol);

            if (strictMode)
            {
                Assert.Single(differences);
                CompatDifference expected = new(DiagnosticIds.AssemblyIdentityMustMatch, string.Empty, DifferenceType.Changed, $"{rightSymbol.Name}, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");
                Assert.Equal(expected, differences.First());
            }
            else
            {
                Assert.Empty(differences);
            }
        }
コード例 #7
0
        private static IDocument GetOrCreateBackingField(this IDocument document, SyntaxAnnotation propertyAnnotation, out IFieldSymbol backingField)
        {
            var semanticModel  = document.GetSemanticModel();
            var property       = document.GetAnnotatedNode <PropertyDeclarationSyntax>(propertyAnnotation);
            var propertySymbol = (IPropertySymbol)semanticModel.GetDeclaredSymbol(property);
            var getter         = property.AccessorList.Accessors.First(a => a.Kind == SyntaxKind.GetAccessorDeclaration);

            if (getter.Body == null)
            {
                // When the getter doesn't have a body (i.e. an auto-prop), we'll need to generate a new field.
                var newField = SymbolFactory.CreateField(
                    attributes: null,
                    accessibility: CommonAccessibility.Private,
                    modifiers: new SymbolModifiers(),
                    type: propertySymbol.Type,
                    name: GenerateFieldName(property, semanticModel));

                var codeGenResult = newField.AddFieldTo(propertySymbol.ContainingType, document.Project.Solution);

                document       = codeGenResult;
                semanticModel  = document.GetSemanticModel();
                property       = document.GetAnnotatedNode <PropertyDeclarationSyntax>(propertyAnnotation);
                propertySymbol = (IPropertySymbol)semanticModel.GetDeclaredSymbol(property);

                backingField = (IFieldSymbol)propertySymbol.ContainingType.GetMembers(newField.Name).Single();

                return(document);
            }
            else
            {
                backingField = GetBackingFieldFromGetter(getter, semanticModel);
                return(document);
            }
        }
コード例 #8
0
        /// <summary>
        /// Create a CIMPointGaphic which can be added to the MapView overlay.
        /// </summary>
        /// <param name="point">The location for the point (as a CIM point)</param>
        /// <returns></returns>
        public CIMPointGraphic MakeCIMPointGraphic(PointN point)
        {
            CIMMarker marker = SymbolFactory.ConstructMarker(Red, 10, SimpleMarkerStyle.Star);

            CIMSymbolLayer[] layers = new CIMSymbolLayer[1];
            layers[0] = marker;

            CIMPointSymbol pointSymbol = new CIMPointSymbol();

            pointSymbol.SymbolLayers = layers;
            pointSymbol.ScaleX       = 1;

            CIMSymbolReference symbolRef = new CIMSymbolReference();

            symbolRef.Symbol = pointSymbol;

            CIMPointGraphic pointGraphic = new CIMPointGraphic();

            ArcGIS.Core.Geometry.SpatialReference spatialRef = SpatialReferenceBuilder.CreateSpatialReference(point.SpatialReference.WKID);
            MapPoint mapPoint = MapPointBuilder.CreateMapPoint(point.X, point.Y, spatialRef);

            pointGraphic.Location = mapPoint;
            pointGraphic.Symbol   = symbolRef;

            return(pointGraphic);
        }
コード例 #9
0
    public static IMultiParser <TInput, TOutput> Setup(Func <Earley <TInput, TOutput> .SymbolFactory, INonterminal <TInput, TOutput> > setup)
    {
        var factory          = new SymbolFactory(new Dictionary <string, ISymbol>());
        var startNonterminal = setup(factory) ?? throw new GrammarException("Setup callback did not return a valid start symbol");

        return(new Parser(startNonterminal));
    }
コード例 #10
0
ファイル: EnumsMustMatchTests.cs プロジェクト: nohwnd/sdk
        public static void AddedEnum()
        {
            string leftSyntax = @"
namespace CompatTests
{
  public enum First {
    A = 0,
    B = 1,
    C = 2,
    D = 3,
  }
}
";

            string          rightSyntax = @"
namespace CompatTests
{
  public enum First {
    D = 3,
    C = 2,
    B = 1,
    A = 0,
  }
  public enum Second {}
}
";
            IAssemblySymbol left        = SymbolFactory.GetAssemblyFromSyntax(leftSyntax);
            IAssemblySymbol right       = SymbolFactory.GetAssemblyFromSyntax(rightSyntax);
            ApiComparer     differ      = new();
            IEnumerable <CompatDifference> differences = differ.GetDifferences(new[] { left }, new[] { right });

            Assert.Empty(differences);
        }
コード例 #11
0
        public void PromotedBaseClassOrInterfaceIsNotReported()
        {
            string leftSyntax = @"
namespace CompatTests
{
  public class First : FirstBase, IFirstInterface { }
  public class Second : SecondBase { }
  public class SecondBase { }
  public class FirstBase { }
  public interface IFirstInterface { }
}
";

            string rightSyntax = @"
namespace CompatTests
{
  public class First : NewBase { }
  public class Second : NewSecondBase { }
  public class NewBase : FirstBase, INewInterface { }
  public class FirstBase { }
  public class SecondBase { }
  public class NewSecondBase : NewSecondBaseBase { }
  public class NewSecondBaseBase : SecondBase { }
  public interface IFirstInterface { }
  public interface INewInterface : IFirstInterface { }
}
";

            IAssemblySymbol left  = SymbolFactory.GetAssemblyFromSyntax(leftSyntax);
            IAssemblySymbol right = SymbolFactory.GetAssemblyFromSyntax(rightSyntax);

            ApiComparer differ = new();

            Assert.Empty(differ.GetDifferences(left, right));
        }
コード例 #12
0
        public static void NoDifferencesWithNoWarn()
        {
            string leftSyntax = @"
namespace CompatTests
{
  public class First
  {
    public void MissingMember() { }
    public int MissingProperty { get; }
    public int MissingField;
  }
}
";

            string rightSyntax = @"
namespace CompatTests
{
  public class First
  {
  }
}
";

            IAssemblySymbol left   = SymbolFactory.GetAssemblyFromSyntax(leftSyntax);
            IAssemblySymbol right  = SymbolFactory.GetAssemblyFromSyntax(rightSyntax);
            ApiDiffer       differ = new();

            differ.NoWarn = DiagnosticIds.MemberMustExist;
            IEnumerable <CompatDifference> differences = differ.GetDifferences(new[] { left }, new[] { right });

            Assert.Empty(differences);
        }
コード例 #13
0
        public static void TypesMissingOnBothSidesAreReported()
        {
            string      leftSyntax  = @"
namespace CompatTests
{
  public class LeftType { }
}
";
            string      rightSyntax = @"
namespace CompatTests
{
  public class RightType { }
}
";
            ApiComparer differ      = new();

            differ.StrictMode = true;
            IAssemblySymbol left  = SymbolFactory.GetAssemblyFromSyntax(leftSyntax);
            IAssemblySymbol right = SymbolFactory.GetAssemblyFromSyntax(rightSyntax);
            IEnumerable <CompatDifference> differences = differ.GetDifferences(left, right);

            List <CompatDifference> expected = new()
            {
                new CompatDifference(DiagnosticIds.TypeMustExist, string.Empty, DifferenceType.Removed, "T:CompatTests.LeftType"),
                new CompatDifference(DiagnosticIds.TypeMustExist, string.Empty, DifferenceType.Added, "T:CompatTests.RightType"),
            };

            Assert.Equal(expected, differences);
        }
        /// <summary>
        /// Method for applying the selected character to the point feature layer
        /// </summary>
        /// <returns></returns>
        private async Task ApplyFontAsMarker()
        {
            var charIndex = 0;

            charIndex = SelectedCharacter.Character;
            var fontName  = SelectedFontFamily.ToString();
            var styleName = SelectedTypeFace.ToString();

            if (MapView.Active != null)
            {
                GetSelectedPointFeatureLayer(); //the selected point feature layer in the TOC
            }
            var cimMarker = SymbolFactory.ConstructMarker(charIndex, fontName,
                                                          styleName, Size); //creating the marker from the Font selected

            var pointSymbolFromMarker = SymbolFactory.ConstructPointSymbol(cimMarker);

            //create a symbol from the marker

            await SetFeatureLayerSymbolAsync(PointFeatureLayer, pointSymbolFromMarker);

            if (IsFavorites)
            {
                await CreateStyleItem();

                if (FontMarkerStyleProjectItem != null && pointSymbolFromMarker != null && !FontMarkerStyleProjectItem.IsReadOnly())
                {
                    await AddStyleItemToStyle(FontMarkerStyleProjectItem, pointSymbolFromMarker); //selected marker is added to the FontMarker style
                }
            }
        }
コード例 #15
0
        private async void EnsureHistoricalTrades()
        {
            if (!Exchange.SupportsHistoricalLoad)
            {
                return;
            }

            Logger.LogInformation("Ensure historical trades are captured.");

            foreach (var symbolCode in ExchangeWorker.Configuration.Symbol)
            {
                var symbol          = SymbolFactory.Get(symbolCode);
                var lastTradeFilter = await HistorianRepository.GetTradeFilter(Exchange.Name, symbolCode);

                var priority = string.Equals(lastTradeFilter, Exchange.GetHttpClient().InitialTradeFilter) ? 2 : 1;

                var catchup = new HistorianTradeCatchup
                {
                    Exchange           = Exchange.Name,
                    SymbolCode         = symbolCode,
                    TradeFilter        = lastTradeFilter,
                    EpochTo            = Epoch.Now,
                    CurrentTradeFilter = lastTradeFilter,
                    Priority           = priority
                };

                await HistorianRepository.AddTradeCatchup(catchup);
            }
        }
コード例 #16
0
        static void Main(string[] args)
        {
            /* IMPORTANT INFORMATION
             * =====================
             *
             * The purpose of this console application is to allow you to test/debug the Strategy
             * while you are developing it.
             *
             * Running this project will perform an EuroFX 6 month backtest on the Strategy, using 30 min bars.
             *
             * Once the backtest is finished, you will be able to launch the TradingMotionSDKToolkit
             * application to see the graphical result.
             *
             * If you want to debug your code you can place breakpoints on the Strategy subclass
             * and Debug the project.
             *
             *
             * REQUIRED CREDENTIALS: Edit your app.config and enter your login/password for accessing the TradingMotion API
             */

            DateTime startBacktestDate = DateTime.Parse(DateTime.Now.AddMonths(-6).AddDays(-1).ToShortDateString() + " 00:00:00");
            DateTime endBacktestDate   = DateTime.Parse(DateTime.Now.AddDays(-1).ToShortDateString() + " 23:59:59");

            TradingMotionAPIClient.Instance.SetUp("https://www.tradingmotion.com/api/webservice.asmx", ConfigurationManager.AppSettings["TradingMotionAPILogin"], ConfigurationManager.AppSettings["TradingMotionAPIPassword"]); //Enter your TradingMotion credentials on the app.config file
            HistoricalDataAPIClient.Instance.SetUp("https://barserver.tradingmotion.com/WSHistoricalDatav2/webservice.asmx");

            AryaStrategy s = new AryaStrategy(new Chart(SymbolFactory.GetSymbol("URO"), BarPeriodType.Minute, 30), null);

            DebugStrategy.RunBacktest(s, startBacktestDate, endBacktestDate);
        }
コード例 #17
0
        public void ShouldRecogniseInversedSymbolWithNoises()
        {
            // given
            var hopfieldNetwork = new HopfieldNetwork();
            var symbolsToLearn  = new List <BipolarSymbol>
            {
                SymbolFactory.CreateBipolarFromDigit(0),
                SymbolFactory.CreateBipolarFromDigit(1),
                SymbolFactory.CreateBipolarFromDigit(2)
            };

            hopfieldNetwork.Learn(symbolsToLearn);

            // when
            bool symbolIsRecognised = hopfieldNetwork.TryRecognise(IversedNumberOneWithNoises());

            // then
            Assert.Equal(1, hopfieldNetwork.IterationsCountOfRecognising);
            Assert.True(symbolIsRecognised);

            BipolarSymbol expectedRecognisedSymbol = SymbolFactory.CreateBipolarFromDigit(1);

            expectedRecognisedSymbol.Inverse();
            Assert.Equal(expectedRecognisedSymbol.ConvertToOneDimensionalArray(), hopfieldNetwork.SymbolsOut);
        }
コード例 #18
0
        public ISymbol DecodeProductId(string productId)
        {
            var baseCurrencyCode  = this.GetStandardisedCurrencyCode(CurrencyFactory, productId.Substring(0, 3));
            var quoteCurrencyCode = this.GetStandardisedCurrencyCode(CurrencyFactory, productId.Substring(4, 3));

            return(SymbolFactory.Get(baseCurrencyCode, quoteCurrencyCode));
        }
コード例 #19
0
ファイル: TypeMustExistTests.cs プロジェクト: nohwnd/sdk
        public void MultipleRightsMissingTypeForwardIsReported()
        {
            string forwardedTypeSyntax = @"
namespace CompatTests
{
  public class ForwardedTestType { }
}
";
            string rightWithForward    = @"
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(CompatTests.ForwardedTestType))]
";

            string[]             rightSyntaxes      = new[] { rightWithForward, "namespace CompatTests { internal class Foo { } }", rightWithForward };
            IEnumerable <string> references         = new[] { forwardedTypeSyntax };
            ElementContainer <IAssemblySymbol> left =
                new(SymbolFactory.GetAssemblyFromSyntax(forwardedTypeSyntax), new MetadataInformation(string.Empty, string.Empty, "ref"));
            IList <ElementContainer <IAssemblySymbol> > right = SymbolFactory.GetElementContainersFromSyntaxes(rightSyntaxes, references);

            ApiComparer differ = new();
            IEnumerable <(MetadataInformation, MetadataInformation, IEnumerable <CompatDifference>)> differences =
                differ.GetDifferences(left, right);

            CompatDifference[][] expected =
            {
                Array.Empty <CompatDifference>(),
                new[]
                {
                    new CompatDifference(DiagnosticIds.TypeMustExist,string.Empty,  DifferenceType.Removed, "T:CompatTests.ForwardedTestType"),
                },
                Array.Empty <CompatDifference>(),
            };

            AssertExtensions.MultiRightResult(left.MetadataInformation, expected, differences);
        }
コード例 #20
0
ファイル: TypeMustExistTests.cs プロジェクト: nohwnd/sdk
        public void NestedTypeVsNamespaces()
        {
            string          leftSyntax                 = @"
namespace A
{
  public class B { }
}
";
            string          rightSyntax                = @"
public class A
{
  public class B { }
}
";
            ApiComparer     differ                     = new();
            bool            enableNullable             = false;
            IAssemblySymbol left                       = SymbolFactory.GetAssemblyFromSyntax(leftSyntax, enableNullable);
            IAssemblySymbol right                      = SymbolFactory.GetAssemblyFromSyntax(rightSyntax, enableNullable);
            IEnumerable <CompatDifference> differences = differ.GetDifferences(new[] { left }, new[] { right });

            CompatDifference[] expected = new[]
            {
                new CompatDifference(DiagnosticIds.TypeMustExist, string.Empty, DifferenceType.Removed, "T:A.B"),
            };

            Assert.Equal(expected, differences);
        }
コード例 #21
0
ファイル: TypeMustExistTests.cs プロジェクト: nohwnd/sdk
        public void MissingTypeFromTypeForwardIsReported()
        {
            string forwardedTypeSyntax = @"
namespace CompatTests
{
  public class ForwardedTestType { }
}
";
            string leftSyntax          = @"
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(CompatTests.ForwardedTestType))]
namespace CompatTests
{
  public class First { }
}
";

            string          rightSyntax = @"
namespace CompatTests
{
  public class First { }
}
";
            IAssemblySymbol left        = SymbolFactory.GetAssemblyFromSyntaxWithReferences(leftSyntax, new[] { forwardedTypeSyntax });
            IAssemblySymbol right       = SymbolFactory.GetAssemblyFromSyntax(rightSyntax);
            ApiComparer     differ      = new();
            IEnumerable <CompatDifference> differences = differ.GetDifferences(left, right);

            CompatDifference[] expected = new[]
            {
                new CompatDifference(DiagnosticIds.TypeMustExist, string.Empty, DifferenceType.Removed, "T:CompatTests.ForwardedTestType")
            };

            Assert.Equal(expected, differences);
        }
コード例 #22
0
ファイル: TypeMustExistTests.cs プロジェクト: nohwnd/sdk
        public static void MultipleRightsNoDifferences()
        {
            string leftSyntax = @"
namespace CompatTests
{
  public class First
  {
    public class FirstNested
    {
      public class SecondNested
      {
        public class ThirdNested
        {
          public string MyField;
        }
      }
    }
  }
}
";

            string[] rightSyntaxes = new[] { leftSyntax, leftSyntax, leftSyntax, leftSyntax };

            ApiComparer differ = new();
            ElementContainer <IAssemblySymbol> left =
                new(SymbolFactory.GetAssemblyFromSyntax(leftSyntax), new MetadataInformation(string.Empty, string.Empty, "ref"));

            IList <ElementContainer <IAssemblySymbol> > right = SymbolFactory.GetElementContainersFromSyntaxes(rightSyntaxes);

            IEnumerable <(MetadataInformation, MetadataInformation, IEnumerable <CompatDifference>)> differences =
                differ.GetDifferences(left, right);

            AssertExtensions.MultiRightEmptyDifferences(left.MetadataInformation, rightSyntaxes.Length, differences);
        }
コード例 #23
0
ファイル: MembersMustExistTests.cs プロジェクト: nohwnd/sdk
        public void ParameterlessConstructorRemovalIsReported()
        {
            string leftSyntax = @"
namespace CompatTests
{
  public sealed class First
  {
  }
}
";

            string rightSyntax = @"
namespace CompatTests
{
  public class First
  {
    private First() { }
  }
}
";

            IAssemblySymbol left  = SymbolFactory.GetAssemblyFromSyntax(leftSyntax);
            IAssemblySymbol right = SymbolFactory.GetAssemblyFromSyntax(rightSyntax);

            ApiComparer differ = new();
            IEnumerable <CompatDifference> differences = differ.GetDifferences(left, right);

            CompatDifference[] expected = new[]
            {
                new CompatDifference(DiagnosticIds.MemberMustExist, string.Empty, DifferenceType.Removed, "M:CompatTests.First.#ctor")
            };

            Assert.Equal(expected, differences);
        }
コード例 #24
0
ファイル: MembersMustExistTests.cs プロジェクト: nohwnd/sdk
        public static void ParametersWithDifferentModifiersNoErrors()
        {
            string leftSyntax = @"
namespace CompatTests
{
  public class First
  {
    public string MyMethod(ref string a) => throw null;
    public void MyOutMethod(out string a) => throw null;
  }
}
";

            string          rightSyntax = @"
namespace CompatTests
{
  public class First
  {
    public string MyMethod(string a) => throw null;
    public void MyOutMethod(string a) { }
  }
}
";
            IAssemblySymbol left        = SymbolFactory.GetAssemblyFromSyntax(leftSyntax);
            IAssemblySymbol right       = SymbolFactory.GetAssemblyFromSyntax(rightSyntax);
            ApiComparer     differ      = new();
            IEnumerable <CompatDifference> differences = differ.GetDifferences(left, right);

            Assert.Empty(differences);
        }
コード例 #25
0
ファイル: MembersMustExistTests.cs プロジェクト: nohwnd/sdk
        public static void MembersWithDifferentNullableAnnotationsNoErrors()
        {
            string leftSyntax = @"
namespace CompatTests
{
  public class First
  {
    public string? MyMethod(string? a) => null;
  }
}
";

            string          rightSyntax = @"
namespace CompatTests
{
  public class First
  {
    public string MyMethod(string a) => null;
  }
}
";
            IAssemblySymbol left        = SymbolFactory.GetAssemblyFromSyntax(leftSyntax, enableNullable: true);
            IAssemblySymbol right       = SymbolFactory.GetAssemblyFromSyntax(rightSyntax);
            ApiComparer     differ      = new();
            IEnumerable <CompatDifference> differences = differ.GetDifferences(left, right);

            Assert.Empty(differences);
        }
コード例 #26
0
        internal async Task AddGraphicToMap(Geometry geom, CIMColor color, bool IsTempGraphic = false, double size = 1.0, string text = "")
        {
            if (geom == null || MapView.Active == null)
            {
                return;
            }

            CIMSymbolReference symbol = null;

            if (!string.IsNullOrWhiteSpace(text) && geom.GeometryType == GeometryType.Point)
            {
                await QueuedTask.Run(() =>
                {
                    //var tg = new CIMTextGraphic() { Placement = Anchor.CenterPoint, Text = text};
                });
            }
            else if (geom.GeometryType == GeometryType.Point)
            {
                await QueuedTask.Run(() =>
                {
                    var s  = SymbolFactory.ConstructPointSymbol(color, size, SimpleMarkerStyle.Circle);
                    symbol = new CIMSymbolReference()
                    {
                        Symbol = s
                    };
                });
            }
            else if (geom.GeometryType == GeometryType.Polyline)
            {
                await QueuedTask.Run(() =>
                {
                    var s  = SymbolFactory.ConstructLineSymbol(color, size);
                    symbol = new CIMSymbolReference()
                    {
                        Symbol = s
                    };
                });
            }
            else if (geom.GeometryType == GeometryType.Polygon)
            {
                await QueuedTask.Run(() =>
                {
                    var outline = SymbolFactory.ConstructStroke(ColorFactory.Black, 1.0, SimpleLineStyle.Solid);
                    var s       = SymbolFactory.ConstructPolygonSymbol(color, SimpleFillStyle.Solid, outline);
                    symbol      = new CIMSymbolReference()
                    {
                        Symbol = s
                    };
                });
            }

            await QueuedTask.Run(() =>
            {
                var disposable = MapView.Active.AddOverlay(geom, symbol);
                overlayObjects.Add(disposable);

                GraphicsList.Add(new ProGraphic(disposable, geom, IsTempGraphic));
            });
        }
コード例 #27
0
ファイル: SymbolTreeRewriter.cs プロジェクト: Laeeth/Cometary
        internal SymbolTreeRewriter(CompilationEditor editor, CSharpCompilation compilation, Func <ISymbol, ISymbol> symbolRewriter)
        {
            this.editor         = editor;
            this.compilation    = compilation;
            this.symbolRewriter = symbolRewriter;

            this.binder = new SymbolFactory(compilation);
        }
コード例 #28
0
        public void CreateApple_Should_Be_AssignableFrom_ISymbol_Interface()
        {
            var symbolFactory = new SymbolFactory();

            var result = symbolFactory.CreateApple();

            Assert.IsAssignableFrom <ISymbol>(result);
        }
コード例 #29
0
        public static InterpreterState StartFromInitialState(ILexemesStack stack)
        {
            var openingBracket = new OpeningBracket(SymbolFactory.CreateSymbol('(', -1));

            stack.Push(openingBracket);

            return(new OpeningBracketOperatorState());
        }
コード例 #30
0
        public void CreateWildcard_Should_Not_Be_Null()
        {
            var symbolFactory = new SymbolFactory();

            var result = symbolFactory.CreateWildcard();

            Assert.NotNull(result);
        }