Exemple #1
0
        protected InspectionResult InspectUsingParam(MemberInfo member, IParam param)
        {
            var inspectionResult = new InspectionResult();

            if (param == null)
            {
                inspectionResult.AddResult(InspectionItem.Ok(member, "NotSetParam"));
                return(inspectionResult);
            }

            foreach (var item in ((IBuildable)param).Build())
            {
                if (_checkers.ContainsKey(item.Key))
                {
                    var result = _checkers[item.Key].Check(member, item.Value);
                    inspectionResult.AddResult(result);
                }
                else
                {
                    throw new InvalidOperationException("Cannot find checker for type " + item.Key);
                }
            }

            return(inspectionResult);
        }
Exemple #2
0
 public DebugMonitor()
 {
     filterPid  = new NumberParam("Filter PID", 0);
     filterText = new TextParam("Filter Text", "");
     listen     = new BoolParam("Listen", true);
     parameters = new IParam[] { listen, filterPid, filterText };
 }
        public static IParamControl GetParamControl(IParam param)
        {
            IParamControl con = null;

            if (param is CoOrdinatesParam)
            {
                con = new CoOrdinatesControl((CoOrdinatesParam)param);
            }
            else if (param is NumberParam)
            {
                con = new NumberControl((NumberParam)param);
            }
            else if (param is TextParam)
            {
                con = new TextControl((TextParam)param);
            }
            else if (param is BoolParam)
            {
                con = new BoolControl((BoolParam)param);
            }
            else if (param is KeyValueParam)
            {
                KeyValueParam kvp = (KeyValueParam)param;
                con = new KeyValueControl();// (GetComboBox(key, kvp.KeyValuePairs, kvp.KeyString, kvp.ValueString));
            }

            return(con);
        }
Exemple #4
0
        public ParamNode(DocumentIdNode documentIdNode, IParam param)
        {
            Infra.NotNull(param.Name);

            documentIdNode.SaveToSlot(out _documentIdSlot);
            _param = param;
        }
Exemple #5
0
        public static async Task <int> GetDurationAsync(Media media, List <IParam> parameters, CancellationToken token)
        {
            int    duration  = 0;
            IParam startTime = parameters.Find(e => e.Key == "-ss");
            IParam endTime   = parameters.Find(e => e.Key == "-to");

            int[]          times      = new int[] { 3600, 60, 1 };
            string         commandStr = $"-i \"{media.Path}\"";
            ProcessCommand process    = new ProcessCommand(commandStr, token);

            await foreach (string result in process.ResultAsync(token))
            {
                log.Info(result);
                if (result != null && result.Contains("Duration"))
                {
                    Match regex = new Regex(@"Duration: (\d+):(\d+):(\d+)").Match(result);
                    duration = regex.Groups.Values.TakeLast(3).Zip(times).Select((f, s) => f.First.Value.ToInt() * f.Second).Sum();
                    log.Info($"duration: {duration}");
                    break;
                }
            }

            duration  = endTime?.Value?.ToSeconds() ?? duration;
            duration -= startTime?.Value?.ToSeconds() ?? 0;

            return(duration);
        }
        public ConfigurationModule Set <T, U>(IParam <T> opt, GenericType <U> val)
            where U : T
        {
            Type   t = typeof(U);
            string n = ReflectionUtilities.GetAssemblyQualifiedName(t);

            return(Set(opt, n));
        }
        public ConfigurationModule Set <T>(IParam <IList <T> > opt, IList <string> impl)
        {
            ConfigurationModule c = DeepCopy();

            c.ProcessSet(opt);
            c.setParamLists.Add(opt, impl);
            return(c);
        }
Exemple #8
0
        public void IParam_Value(bool?value)
        {
            var param = new ParamBoolean(value, ParameterDirection.Input);

            IParam <bool> bolParam = param;

            Assert.NotNull(bolParam);
            Assert.Equal(value ?? false, bolParam.Value);
        }
Exemple #9
0
        public string Get(IParam param)
        {
            string s = Console.ReadLine();

            if (string.Empty.Equals(s))
            {
                return(param.Value.ToString());
            }
            return(s);
        }
Exemple #10
0
        public TestWindows()
        {
            windows = new List <WindowInfo>();

            xyParam       = new CoOrdinatesParam();
            printParent   = new BoolParam("Print Parent", false);
            printChildren = new BoolParam("Print Children", false);
            filter        = new TextParam("Filter", "");
            allTopWins    = new BoolParam("-Only Print TopWindows", false);
            parameters    = new IParam[] { xyParam, printParent, printChildren, allTopWins, filter };
        }
Exemple #11
0
        /// <summary>
        /// Views one of the constructors defined on the item
        /// </summary>
        /// <param name="index"></param>
        private void ViewConstructor(int index)
        {
            m_CurrentCtor = m_Item.AdditionalCtors[index] as ConstructorDef;

            m_Param1 = AddParam(m_CurrentCtor.Param1, new Point(4, 20));

            if (m_CurrentCtor.Param2 != null)
            {
                m_Param2 = AddParam(m_CurrentCtor.Param2, new Point(104, 20));
            }
        }
Exemple #12
0
        public ConfigurationModuleBuilder BindList <U, T>(GenericType <U> iface, IParam <IList <T> > opt)
            where U : Name <IList <T> >
        {
            ConfigurationModuleBuilder c = DeepCopy();
            Type ifaceType = typeof(U);

            c.ProcessUse(opt);

            c.FreeParams.Add(ifaceType, opt);
            return(c);
        }
    public void Notify(EventName eventName, IParam parameters)
    {
        HashSet <ISubscriber> subList;

        if (eventMap.TryGetValue(eventName, out subList))
        {
            foreach (ISubscriber subscriber in subList)
            {
                subscriber.Notify(eventName, parameters);
            }
        }
    }
Exemple #14
0
 private void AddParameterControls(IParam[] parameters)
 {
     if (parameters != null)
     {
         for (int i = 0; i < parameters.Length; i++)
         {
             IParam        param   = parameters[i];
             IParamControl control = ParamsControlFactory.GetParamControl(param);
             flowLayoutPanelParameters.Controls.Add(control.GetControl());
         }
     }
 }
 public override string Provide(IParam parameter)
 {
     if (parameter is ParamImplementation1)
     {
         return("value for implementation 1");
     }
     if (parameter is ParamImplementation2)
     {
         return("value for implementation 2");
     }
     return("default value");
 }
Exemple #16
0
        public static void ClearSEAORUnsupportedTag(CorridorState corridorState)
        {
            if (corridorState == null)
            {
                throw new ArgumentNullException("corridorState");
            }
            IParam param = corridorState.ParamsLong.Add("SE AOR Unsupported", 0);

            if (param != null)
            {
                param.Access = ParamAccessType.Output;
            }
        }
Exemple #17
0
        public TestProcess()
        {
            //pidParam = new NumberParam("PID", 0);
            filterModuleParam = new TextParam("Filter", "");
            showFilePath      = new BoolParam("File Path", false);
            showDesc          = new BoolParam("Description", false);
            showComments      = new BoolParam("Comments", false);
            showVersion       = new BoolParam("Version", false);
            showCompany       = new BoolParam("Company", false);
            showMemory        = new BoolParam("Memory", false);

            parameters = new IParam[] { xyParam, /*pidParam,*/ filterModuleParam, showFilePath, showVersion, showDesc, showCompany, showMemory, showComments };
        }
Exemple #18
0
        public DefaultParam(IParam param)
        {
            if (param is null)
            {
                throw new ArgumentNullException(nameof(param));
            }

            Infra.NotNull(param.Name);

            _param = param;
            ExpressionEvaluator = param.Expression?.As <IObjectEvaluator>();
            LocationEvaluator   = param.Location?.As <ILocationEvaluator>();
        }
Exemple #19
0
        XmlNode Param2Node(IParam param)
        {
            switch (param.TypeKey)
            {
            case ParamType.@struct:
                return(ParamStruct2Node(param as ParamStruct));

            case ParamType.list:
                return(ParamArray2Node(param as ParamList));

            default:
                return(ParamValue2Node(param as ParamValue));
            }
        }
Exemple #20
0
 public void AddParameters(IParam[] paramss)
 {
     if (parameters != null)
     {
         IParam[] parameters1 = new IParam[parameters.Length + paramss.Length];
         Array.Copy(parameters, parameters1, parameters.Length);
         Array.Copy(paramss, 0, parameters1, parameters.Length, paramss.Length);
         parameters = parameters1;
     }
     else
     {
         parameters = paramss;
     }
 }
Exemple #21
0
        public ConfigurationModuleBuilder BindSetEntry <U, T>(GenericType <U> iface, IParam <T> opt)
            where U : Name <ISet <T> >
        {
            ConfigurationModuleBuilder c = DeepCopy();
            Type ifaceType = typeof(U);

            c.ProcessUse(opt);

            c.FreeParams.Add(ifaceType, opt);
            if (!SetOpts.Contains(opt))
            {
                c.SetOpts.Add(opt);
            }
            return(c);
        }
Exemple #22
0
        ////TODO
        ////public readonly ConfigurationModule set(Param<? extends Number> opt, Number val)
        ////{
        ////   return set(opt, val);
        ////}

        public ConfigurationModule Set <T>(IParam <T> opt, string val)
        {
            ConfigurationModule c = DeepCopy();

            c.ProcessSet(opt);
            if (c.Builder.SetOpts.Contains(opt))
            {
                c.setParamSets.Add(opt, val);
            }
            else
            {
                c.setParams.Add(opt, val);
            }
            return(c);
        }
Exemple #23
0
 public static void SetSEAORCrownPointForLayout(CorridorState corridorState, int nCrownPoint)
 {
     if (corridorState == null)
     {
         throw new ArgumentNullException("corridorState");
     }
     checked
     {
         long   nCPlusPlusIndex = nCrownPoint - 1;
         IParam param           = corridorState.ParamsLong.Add("SE AOR Crown Point For Layout", (int)nCPlusPlusIndex);
         if (param != null)
         {
             param.Access = ParamAccessType.Output;
         }
     }
 }
Exemple #24
0
        /// <summary>
        /// Removes the controls for the current parameters
        /// </summary>
        private void CleanUp()
        {
            if (m_Param1 != null)
            {
                (m_Param1 as Control).Visible = false;
                Controls.Remove(m_Param1 as UserControl);
                (m_Param1 as UserControl).Dispose();
                m_Param1 = null;
            }

            if (m_Param2 != null)
            {
                (m_Param2 as Control).Visible = false;
                Controls.Remove(m_Param2 as UserControl);
                (m_Param2 as UserControl).Dispose();
                m_Param2 = null;
            }
        }
Exemple #25
0
        public void Say(
            int val,
            out int oval,
            string str,
            out string ostr,
            long[] arr,
            out long[] oarr,
            IParam param,
            out IParam oparam
            )
        {
            oval = -val;
            Console.WriteLine("{0}, {1}", val, oval);

            ostr = str.ToUpper();
            Console.WriteLine("{0}, {1}", str, ostr);

            Console.WriteLine("{0}", arr);
            oarr = (long[])arr.Clone();
            for (int ii = 0; ii < oarr.Length; ++ii)
            {
                oarr[ii] = -oarr[ii];
            }
            Console.WriteLine("{0}", oarr);

            oparam = new CParam
            {
                Value     = -param.Value,
                Message   = param.Message.ToUpper(),
                ArrayData = (long[])param.ArrayData.Clone()
            };

            for (int ii = 0; ii < oparam.ArrayData.Length; ++ii)
            {
                oparam.ArrayData[ii] = -oparam.ArrayData[ii];
            }

            Console.WriteLine("{0}, {1}, {2}", param.Value, param.Message, param.ArrayData);
            Console.WriteLine("{0}, {1}, {2}", oparam.Value, oparam.Message, oparam.ArrayData);
        }
Exemple #26
0
        private void IterateHashes(IParam param)
        {
            switch (param.TypeKey)
            {
            case ParamType.@struct:
                foreach (var item in (param as ParamStruct).Nodes)
                {
                    WriteHash(item.Key);
                    IterateHashes(item.Value);
                }
                break;

            case ParamType.list:
                foreach (var item in (param as ParamList).Nodes)
                {
                    IterateHashes(item);
                }
                break;

            case ParamType.hash40:
                WriteHash((ulong)(param as ParamValue).Value);
                break;
            }
        }
 internal void M(IParam p)
 {
     Console.WriteLine("Inside M1");
 }
Exemple #28
0
 protected AbstractParamControl(IParam param)
 {
     param.ValueChanged += new ValueChangedDelegate(this.UpdateValue);
 }
 public abstract T Provide(IParam parameter);
 public T Get(IParam parameter)
 {
     return((this as dynamic).Provide(parameter as dynamic));
 }
 public string Provide(IParam parameter)
 {
     return("default value");
 }
		/// <summary>
		/// Removes the controls for the current parameters
		/// </summary>
		private void CleanUp()
		{
			if ( m_Param1 != null )
			{
				( m_Param1 as Control ).Visible = false;
				Controls.Remove( m_Param1 as UserControl );
				( m_Param1 as UserControl ).Dispose();
				m_Param1 = null;
			}

			if ( m_Param2 != null )
			{
				( m_Param2 as Control ).Visible = false;
				Controls.Remove( m_Param2 as UserControl );
				( m_Param2 as UserControl ).Dispose();
				m_Param2 = null;
			}
		}
		/// <summary>
		/// Views one of the constructors defined on the item
		/// </summary>
		/// <param name="index"></param>
		private void ViewConstructor( int index )
		{
			m_CurrentCtor = m_Item.AdditionalCtors[ index ] as ConstructorDef;

			m_Param1 = AddParam( m_CurrentCtor.Param1, new Point( 4, 20 ) );

			if ( m_CurrentCtor.Param2 != null )
			{
				m_Param2 = AddParam( m_CurrentCtor.Param2, new Point( 104, 20 ) );
			}
		}
 public void BeginRebind(IParam param)
 {
 }
 internal void M(IParam p1, IParam p2)
 {
     Console.WriteLine("Inside M6");
 }