Exemple #1
0
 public MockGraphContext(EtpUri uri, EtpDataObjectType dataObjectType)
 {
     Uri                    = uri;
     IncludeSelf            = false;
     IncludeSources         = true;
     Depth                  = 1;
     NavigatePrimaryEdges   = true;
     NavigateSecondaryEdges = true;
     if (dataObjectType != null)
     {
         DataObjectTypes = new HashSet <EtpDataObjectType> {
             dataObjectType
         }
     }
     ;
 }
Exemple #2
0
        private MockGraphContext GetContext(string uri)
        {
            var context = new MockGraphContext
            {
                Uri                     = new EtpUri(uri),
                DataObjectTypes         = new HashSet <EtpDataObjectType>(),
                Depth                   = 1,
                IncludeSelf             = false,
                IncludeSources          = true,
                IncludeTargets          = false,
                IncludeSecondarySources = false,
                IncludeSecondaryTargets = false,
                NavigatePrimaryEdges    = true,
                NavigateSecondaryEdges  = false,
            };

            while (true)
            {
                Console.WriteLine("Choose an option:");
                Console.WriteLine($" D - Set depth (current value: {context.Depth})");
                Console.WriteLine($" S - Toggle Include Self (current value: {(context.IncludeSelf ? "Include" : "Exclude")})");
                Console.WriteLine($" O - Toggle Include Sources (current value: {(context.IncludeSources ? "Include" : "Exclude")})");
                Console.WriteLine($" P - Toggle Include Secondary Sources (current value: {(context.IncludeSecondarySources ? "Include" : "Exclude")})");
                Console.WriteLine($" T - Toggle Include Targets (current value: {(context.IncludeTargets ? "Include" : "Exclude")})");
                Console.WriteLine($" U - Toggle Include Secondary Targets (current value: {(context.IncludeSecondaryTargets ? "Include" : "Exclude")})");
                Console.WriteLine($" 1 - Toggle Navigate Primary Edges (current value: {(context.NavigatePrimaryEdges ? "Navigate" : "Do Not Navigate")})");
                Console.WriteLine($" 2 - Toggle Navigate Secondary Edges (current value: {(context.NavigateSecondaryEdges ? "Navigate" : "Do Not Navigate")})");
                Console.WriteLine($" Y - Add Data Types");
                if (context.DataObjectTypes.Count > 0)
                {
                    Console.WriteLine($"     Current Data Types:");
                    foreach (var dataType in context.DataObjectTypes)
                    {
                        Console.WriteLine($"       {dataType}");
                    }
                }
                Console.WriteLine($" (enter / other) - Submit request");
                Console.WriteLine();

                var info = Console.ReadKey();

                Console.WriteLine(" - processing...");
                Console.WriteLine();
                if (IsKey(info, "D"))
                {
                    Console.WriteLine("Enter depth:");
                    var depth = Console.ReadLine();
                    int depthValue;
                    if (int.TryParse(depth, out depthValue))
                    {
                        context.Depth = depthValue;
                    }
                }
                else if (IsKey(info, "S"))
                {
                    context.IncludeSelf = !context.IncludeSelf;
                }
                else if (IsKey(info, "O"))
                {
                    context.IncludeSources = !context.IncludeSources;
                }
                else if (IsKey(info, "P"))
                {
                    context.IncludeSecondarySources = !context.IncludeSecondarySources;
                }
                else if (IsKey(info, "T"))
                {
                    context.IncludeTargets = !context.IncludeTargets;
                }
                else if (IsKey(info, "U"))
                {
                    context.IncludeSecondaryTargets = !context.IncludeSecondaryTargets;
                }
                else if (IsKey(info, "1"))
                {
                    context.NavigatePrimaryEdges = !context.NavigatePrimaryEdges;
                }
                else if (IsKey(info, "2"))
                {
                    context.NavigateSecondaryEdges = !context.NavigateSecondaryEdges;
                }
                else if (IsKey(info, "Y"))
                {
                    Console.WriteLine("Enter data type:");
                    var dataType      = Console.ReadLine();
                    var dataTypeValue = new EtpDataObjectType(dataType);
                    if (dataTypeValue.IsValid)
                    {
                        context.DataObjectTypes.Add(dataTypeValue);
                    }
                }
                else
                {
                    break;
                }
            }

            return(context);
        }