本文整理匯總了C#中OpenSource.UPnP.UPnPService.InvokeSync方法的典型用法代碼示例。如果您正苦於以下問題:C# UPnPService.InvokeSync方法的具體用法?C# UPnPService.InvokeSync怎麽用?C# UPnPService.InvokeSync使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OpenSource.UPnP.UPnPService
的用法示例。
在下文中一共展示了UPnPService.InvokeSync方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Invoke
public void Invoke(UPnPService S, string Action, byte[] InArgs, out byte[] OutArgs)
{
UPnPAction A = S.GetAction(Action);
ArrayList AList = new ArrayList();
foreach(UPnPArgument arg in A.ArgumentList)
{
if(arg.IsReturnValue==false && arg.Direction=="out")
{
UPnPArgument _arg = (UPnPArgument)arg.Clone();
_arg.DataValue = UPnPService.CreateObjectInstance(arg.RelatedStateVar.GetNetType(),null);
AList.Add(_arg);
}
}
UPnPArgument[] Temp = ParseArguments(InArgs);
foreach(UPnPArgument _arg in Temp)
{
_arg.DataType = A.GetArg(_arg.Name).RelatedStateVar.ValueType;
_arg.Direction = "in";
AList.Add(_arg);
}
UPnPArgument[] Arguments = (UPnPArgument[])AList.ToArray(typeof(UPnPArgument));
(new UPnPDebugObject(S)).SetProperty("ValidationMode",false);
object RetVal = null;
try
{
RetVal = S.InvokeSync(Action,Arguments);
}
catch(UPnPInvokeException ie)
{
if(ie.UPNP!=null)
{
throw(ie.UPNP);
}
else
{
throw(ie);
}
}
ArrayList RetList = new ArrayList();
if(A.HasReturnValue==true)
{
UPnPArgument RA = (UPnPArgument)A.GetRetArg().Clone();
RA.DataValue = RetVal;
RetList.Add(RA);
}
foreach(UPnPArgument OA in Arguments)
{
if(OA.Direction=="out")
{
RetList.Add(OA);
}
}
OutArgs = BuildArguments((UPnPArgument[])RetList.ToArray(typeof(UPnPArgument)));
}
示例2: BasicControlTest_ACTION_BadAllowedValues
private bool BasicControlTest_ACTION_BadAllowedValues(UPnPService s, UPnPAction A)
{
(new UPnPDebugObject(s)).SetProperty("ValidationMode",false);
ArrayList ArgList = null;
foreach(UPnPArgument arg in A.ArgumentList)
{
if(arg.IsReturnValue==false && arg.Direction=="in")
{
if(arg.RelatedStateVar.AllowedStringValues!=null)
{
ArgList = BasicControlTest_BuildActionArgs(A);
for(int i=0;i<ArgList.Count;++i)
{
if(((UPnPArgument)ArgList[i]).Name==arg.Name)
{
string val = "[email protected]#$";
bool OK = true;
do
{
OK = true;
for(int j=0;j<arg.RelatedStateVar.AllowedStringValues.Length;++j)
{
if(val==arg.RelatedStateVar.AllowedStringValues[j])
{
OK = false;
break;
}
}
if(OK==false) val += val;
}while (OK==false);
((UPnPArgument)ArgList[i]).DataValue = val;
AddEvent(LogImportance.Remark,"Allowed Values","Invoke <<Bad " + arg.Name + ">> " + A.Name);
try
{
s.InvokeSync(A.Name,(UPnPArgument[])ArgList.ToArray(typeof(UPnPArgument)));
WARN_ALLOWED = true;
AddEvent(LogImportance.High,"Allowed Values"," Device failed to validate argument");
}
catch(UPnPInvokeException ex)
{
if(ex.UPNP!=null)
{
if(ex.UPNP.ErrorCode<501)
{
AddEvent(LogImportance.Remark,"Allowed Values"," Device SUCCESSFULLY validated argument");
}
else
{
WARN_ALLOWED = true;
AddEvent(LogImportance.Remark,"Allowed Values"," Device returned code: " + ex.UPNP.ErrorCode.ToString() + " but failed to validate argument");
}
}
else
{
FAIL_ALLOWED = true;
AddEvent(LogImportance.Critical,"Allowed Values"," Device returned non SOAP-Encoded Error");
}
}
}
}
}
}
}
(new UPnPDebugObject(s)).SetProperty("ValidationMode",true);
return true;
}
示例3: BasicControlTest_ACTION_BadRange
private bool BasicControlTest_ACTION_BadRange(UPnPService s, UPnPAction A)
{
(new UPnPDebugObject(s)).SetProperty("ValidationMode",false);
ArrayList ArgList = null;
foreach(UPnPArgument arg in A.ArgumentList)
{
if(arg.IsReturnValue==false && arg.Direction=="in")
{
if(arg.RelatedStateVar.Maximum!=null ||
arg.RelatedStateVar.Minimum!=null)
{
ArgList = BasicControlTest_BuildActionArgs(A);
for(int i=0;i<ArgList.Count;++i)
{
if(((UPnPArgument)ArgList[i]).Name==arg.Name)
{
if(arg.RelatedStateVar.Minimum!=null)
{
FieldInfo mi = arg.RelatedStateVar.GetNetType().GetField("MinValue");
if(mi.GetValue(null).ToString()!=arg.RelatedStateVar.Minimum.ToString())
{
((UPnPArgument)ArgList[i]).DataValue = mi.GetValue(null);
AddEvent(LogImportance.Remark,"Range","Invoke <<" + arg.Name + " value too small>> " + A.Name);
try
{
s.InvokeSync(A.Name,(UPnPArgument[])ArgList.ToArray(typeof(UPnPArgument)));
WARN_RANGE = true;
AddEvent(LogImportance.High,"Range"," Device failed to validate argument");
}
catch(UPnPInvokeException ex)
{
if(ex.UPNP!=null)
{
if(ex.UPNP.ErrorCode<501)
{
AddEvent(LogImportance.Remark,"Range"," Device SUCCESSFULLY validated argument");
}
else
{
WARN_RANGE = true;
AddEvent(LogImportance.High,"Range"," Device returned code: " + ex.UPNP.ErrorCode.ToString() + " but failed to validate argument");
}
}
else
{
FAIL_RANGE = true;
AddEvent(LogImportance.Critical,"Range"," Device returned non SOAP-Encoded Error");
}
}
}
}
if(arg.RelatedStateVar.Maximum!=null)
{
FieldInfo mi = arg.RelatedStateVar.GetNetType().GetField("MaxValue");
if(mi.GetValue(null).ToString()!=arg.RelatedStateVar.Maximum.ToString())
{
((UPnPArgument)ArgList[i]).DataValue = mi.GetValue(null);
AddEvent(LogImportance.Remark,"Range","Invoke <<" + arg.Name + " value too big>> " + A.Name);
try
{
s.InvokeSync(A.Name,(UPnPArgument[])ArgList.ToArray(typeof(UPnPArgument)));
WARN_RANGE = true;
AddEvent(LogImportance.High,"Range"," Device failed to validate argument");
}
catch(UPnPInvokeException ex)
{
if(ex.UPNP!=null)
{
if(ex.UPNP.ErrorCode<501)
{
AddEvent(LogImportance.Remark,"Range"," Device SUCCESSFULLY validated argument");
}
else
{
WARN_RANGE = true;
AddEvent(LogImportance.High,"Range"," Device returned code: " + ex.UPNP.ErrorCode.ToString() + " but failed to validate argument");
}
}
else
{
FAIL_RANGE = true;
AddEvent(LogImportance.Critical,"Range"," Device returned non SOAP-Encoded Error");
}
}
}
}
}
}
}
}
}
(new UPnPDebugObject(s)).SetProperty("ValidationMode",true);
return true;
//.........這裏部分代碼省略.........
示例4: BasicControlTest_ACTION
private bool BasicControlTest_ACTION(UPnPService s, UPnPAction A)
{
ArrayList ArgList = BasicControlTest_BuildActionArgs(A);
try
{
s.InvokeSync(A.Name,(UPnPArgument[])ArgList.ToArray(typeof(UPnPArgument)));
AddEvent(LogImportance.Remark,"Valid Values","Invoke: " + A.Name + " << OK >>");
}
catch(UPnPInvokeException ex)
{
if(ex.UPNP.ErrorCode==401 ||
ex.UPNP.ErrorCode==402)
{
// Oh really?
WARN_VALID = true;
AddEvent(LogImportance.High,"Valid Values",
" Invoke: " + A.Name);
AddEvent(LogImportance.High,"Valid Values",
" Cannot return Error Code " + ex.UPNP.ErrorCode.ToString());
foreach(UPnPArgument _arg in ex.Arguments)
{
AddEvent(LogImportance.High,"Valid Values",
" " + _arg.Name + ": " + UPnPService.SerializeObjectInstance(_arg.DataValue));
}
}
else
{
// Fine, I suppose
AddEvent(LogImportance.Remark,"Valid Values",
"Invoke: " + A.Name + " << " + ex.UPNP.ErrorCode + " " + ex.UPNP.ErrorDescription + " OK >>");
}
}
return true;
}