protected void AddStateVariable(StateVariable stateVariable)
 {
     if (stateVariable == null)
     {
         throw new ArgumentNullException("stateVariable");
     }
     state_variables.SetItem(stateVariable.Name, stateVariable);
 }
Ejemplo n.º 2
0
 public void QueueUpdate(StateVariable stateVariable)
 {
     lock (this) {
         if (!updated_state_variables.Contains (stateVariable)) {
             updated_state_variables.Add (stateVariable);
             Monitor.Pulse (this);
         }
     }
 }
Ejemplo n.º 3
0
        private void WriteStateVariable(CodeMonkey monkey, StateVariable state_variable)
        {
            string type = GetTypeName (state_variable.Type);

            monkey.WriteLine (@"[UpnpStateVariable (""{0}"")]", state_variable.Name);
            monkey.WriteLine ("public event EventHandler<StateVariableChangedArgs<{0}>> {1}Changed;", type, state_variable.Name);

            monkey.StartWriteBlock ("protected {0} {1}", type, state_variable.Name, false);
            monkey.StartWriteBlock ("set", false);
            monkey.WriteLine ("EventHandler<StateVariableChangedArgs<{0}>> handler = {1}Changed;", type, state_variable.Name);
            monkey.StartWriteBlock ("if (handler != null)", false);
            monkey.WriteLine ("handler (this, new StateVariableChangedArgs<{0}> (value));", type);
            monkey.EndWriteBlock ();
            monkey.EndWriteBlock ();
            monkey.EndWriteBlock ();
            monkey.WriteLine ();
        }
Ejemplo n.º 4
0
 static ServiceController CreateServiceController (StateVariable stateVariable1, StateVariable stateVariable2)
 {
     return new ServiceController (
         new[] {
             new ServiceAction (
                 "Foo",
                 new[] {
                     new Argument ("bar", "X_ARG_bar", ArgumentDirection.In),
                     new Argument ("result", "X_ARG_result", ArgumentDirection.Out)
                 },
                 arguments => {
                     var out_arguments = new Dictionary<string, string> (1);
                     out_arguments["result"] = string.Format ("You said {0}", arguments["bar"]);
                     return out_arguments;
                 }
             )
         },
         new[] {
             new StateVariable ("X_ARG_bar", "string"),
             new StateVariable ("X_ARG_result", "string"),
             stateVariable1,
             stateVariable2
         }
     );
 }
Ejemplo n.º 5
0
 static ServiceController CreateServiceController (StateVariable stateVariable)
 {
     return CreateServiceController (stateVariable, null);
 }
Ejemplo n.º 6
0
 internal void UpdateStateVariable(StateVariable stateVariable)
 {
     event_server.QueueUpdate(stateVariable);
 }
Ejemplo n.º 7
0
 public static void AssertEquality (StateVariable sourceStateVariable, StateVariable targetStateVariable)
 {
     Assert.AreEqual (sourceStateVariable.Name, targetStateVariable.Name);
     Assert.AreEqual (sourceStateVariable.DataType, targetStateVariable.DataType);
     Assert.AreEqual (sourceStateVariable.SendsEvents, targetStateVariable.SendsEvents);
     Assert.AreEqual (sourceStateVariable.IsMulticast, targetStateVariable.IsMulticast);
     Assert.AreEqual (sourceStateVariable.DefaultValue, targetStateVariable.DefaultValue);
     if (sourceStateVariable.AllowedValues != null) {
         var source_values = sourceStateVariable.AllowedValues.GetEnumerator ();
         var target_values = targetStateVariable.AllowedValues.GetEnumerator ();
         while (source_values.MoveNext ()) {
             Assert.IsTrue (target_values.MoveNext ());
             Assert.AreEqual (source_values.Current, target_values.Current);
         }
         Assert.IsFalse (target_values.MoveNext ());
     }
     if (sourceStateVariable.AllowedValueRange != null) {
         Assert.AreEqual (sourceStateVariable.AllowedValueRange.Minimum, targetStateVariable.AllowedValueRange.Minimum);
         Assert.AreEqual (sourceStateVariable.AllowedValueRange.Maximum, targetStateVariable.AllowedValueRange.Maximum);
         Assert.AreEqual (sourceStateVariable.AllowedValueRange.Step, targetStateVariable.AllowedValueRange.Step);
     }
 }
 protected void AddStateVariable(StateVariable stateVariable)
 {
     if (stateVariable == null) throw new ArgumentNullException ("stateVariable");
     state_variables.SetItem (stateVariable.Name, stateVariable);
 }